Skip to content

Commit 8542897

Browse files
author
anacforcelli
committed
Fix I2C and add PWM-dummy support
1 parent 076cc59 commit 8542897

File tree

10 files changed

+207
-69
lines changed

10 files changed

+207
-69
lines changed

boards.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -551,29 +551,29 @@ puppy.bootloader.address=0x11000
551551

552552
##############################################################################################################
553553

554-
puppy.name=poodleino-toy-v1
555-
puppy.build.core=arduino
556-
puppy.build.board=poodleino-toy-v1
557-
puppy.build.zephyr_target=poodleino-toy-v1
558-
puppy.build.variant=poodleino-toy-v1_puppy_v2
559-
560-
puppy.build.crossprefix=riscv64-zephyr-elf-
561-
puppy.build.compiler_path=/home/ana/zephyr-sdk-0.16.8/riscv64-zephyr-elf/bin/
562-
puppy.compiler.zephyr=
563-
puppy.compiler.zephyr.arch.define=-DRV_ISA_RV32
564-
puppy.runtime.tools.zephyr-sketch-tool.path=/home/ana/arduino-puppy/ArduinoCore-zephyr/extra/zephyr-sketch-tool
565-
566-
puppy.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
567-
puppy.build.architecture=rv32imfc_zicsr
568-
puppy.build.mcu=rv32imfc_zicsr
569-
570-
puppy.upload.address=0xe1000
571-
puppy.upload.maximum_size=32768
572-
573-
puppy.bootloader.tool=dfu-util
574-
puppy.bootloader.tool.default=dfu-util
575-
puppy.bootloader.vid=0x2341
576-
puppy.bootloader.pid=0x0364
577-
puppy.bootloader.interface=0
578-
puppy.bootloader.file=zephyr-{build.variant}.bin
579-
puppy.bootloader.address=0x11000
554+
poodleino.name=poodleino-toy-v1
555+
poodleino.build.core=arduino
556+
poodleino.build.board=poodleino-toy-v1
557+
poodleino.build.zephyr_target=poodleino-toy-v1
558+
poodleino.build.variant=poodleino-toy-v1_puppy_v2
559+
560+
poodleino.build.crossprefix=riscv64-zephyr-elf-
561+
poodleino.build.compiler_path=/home/ana/zephyr-sdk-0.16.8/riscv64-zephyr-elf/bin/
562+
poodleino.compiler.zephyr=
563+
poodleino.runtime.tools.zephyr-sketch-tool.path=/home/ana/arduino-puppy/ArduinoCore-zephyr/extra/zephyr-sketch-tool
564+
565+
poodleino.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
566+
poodleino.build.architecture=rv32imafc_zicsr
567+
poodleino.build.mcu=rv32imafc_zicsr
568+
poodleino.build.abi=ilp32
569+
570+
poodleino.upload.address=0xe1000
571+
poodleino.upload.maximum_size=32768
572+
573+
poodleino.bootloader.tool=dfu-util
574+
poodleino.bootloader.tool.default=dfu-util
575+
poodleino.bootloader.vid=0x2341
576+
poodleino.bootloader.pid=0x0364
577+
poodleino.bootloader.interface=0
578+
poodleino.bootloader.file=zephyr-{build.variant}.bin
579+
poodleino.bootloader.address=0x11000

cores/arduino/zephyrCommon.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct gpio_port_callback {
8484
struct arduino_callback handlers[max_ngpios];
8585
gpio_port_pins_t pins;
8686
const struct device *dev;
87-
} port_callback[port_num] = {0};
87+
} port_callback[port_num] = {};
8888

8989
struct gpio_port_callback *find_gpio_port_callback(const struct device *dev) {
9090
for (size_t i = 0; i < ARRAY_SIZE(port_callback); i++) {
@@ -295,7 +295,6 @@ unsigned long millis(void) {
295295
return k_uptime_get_32();
296296
}
297297

298-
#if defined(CONFIG_DAC) || defined(CONFIG_PWM)
299298
static int _analog_write_resolution = 8;
300299

301300
void analogWriteResolution(int bits) {
@@ -305,9 +304,8 @@ void analogWriteResolution(int bits) {
305304
int analogWriteResolution() {
306305
return _analog_write_resolution;
307306
}
308-
#endif
309307

310-
#ifdef CONFIG_PWM
308+
#if defined(CONFIG_PWM)
311309

312310
void analogWrite(pin_size_t pinNumber, int value) {
313311
size_t idx = pwm_pin_index(pinNumber);
@@ -335,9 +333,7 @@ void analogWrite(pin_size_t pinNumber, int value) {
335333
(void)pwm_set_pulse_dt(&arduino_pwm[idx], value);
336334
}
337335

338-
#endif
339-
340-
#ifdef CONFIG_DAC
336+
#elif defined(CONFIG_DAC)
341337
void analogWrite(enum dacPins dacName, int value) {
342338
if (dacName >= NUM_OF_DACS) {
343339
return;
@@ -349,6 +345,13 @@ void analogWrite(enum dacPins dacName, int value) {
349345
dac_write_value(dac_dev, dac_ch_cfg[dacName].channel_id,
350346
map(value, 0, 1 << _analog_write_resolution, 0, max_dac_value));
351347
}
348+
#else
349+
350+
void analogWrite(pin_size_t pinNumber, int value) {
351+
if (value < 128) digitalWrite(pinNumber, 0);
352+
else digitalWrite(pinNumber, 1);
353+
}
354+
352355
#endif
353356

354357
#ifdef CONFIG_ADC

cores/arduino/zephyrSerial.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ size_t arduino::ZephyrSerial::write(const uint8_t *buffer, size_t size) {
160160
k_sem_take(&tx.sem, K_FOREVER);
161161
auto ret = ring_buf_put(&tx.ringbuf, &buffer[idx], size - idx);
162162
k_sem_give(&tx.sem);
163-
if (ret < 0) {
164-
return 0;
165-
}
166163
idx += ret;
167164
if (ret == 0) {
168165
uart_irq_tx_enable(uart);

libraries/Wire/Wire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static struct i2c_target_callbacks target_callbacks = {
4848
.stop = i2c_target_stop_cb,
4949
};
5050

51-
arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_dev(i2c), i2c_cfg({0}) {
51+
arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_dev(i2c), i2c_cfg({}) {
5252
ring_buf_init(&txRingBuffer.rb, sizeof(txRingBuffer.buffer), txRingBuffer.buffer);
5353
ring_buf_init(&rxRingBuffer.rb, sizeof(rxRingBuffer.buffer), rxRingBuffer.buffer);
5454
}

loader/llext_exports.c

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,131 @@ FORCE_EXPORT_SYM(__aeabi_ul2f);
253253
FORCE_EXPORT_SYM(__aeabi_dcmpge);
254254

255255
#elif defined(CONFIG_RISCV)
256+
FORCE_EXPORT_SYM(__adddf3);
257+
FORCE_EXPORT_SYM(__addsf3);
258+
FORCE_EXPORT_SYM(__addtf3);
259+
FORCE_EXPORT_SYM(__subsf3);
260+
FORCE_EXPORT_SYM(__subdf3);
261+
FORCE_EXPORT_SYM(__subtf3);
262+
FORCE_EXPORT_SYM(__mulsf3);
263+
FORCE_EXPORT_SYM(__muldf3);
264+
FORCE_EXPORT_SYM(__multf3);
265+
FORCE_EXPORT_SYM(__divsf3);
266+
FORCE_EXPORT_SYM(__divdf3);
267+
FORCE_EXPORT_SYM(__divtf3);
268+
FORCE_EXPORT_SYM(__negsf2);
269+
FORCE_EXPORT_SYM(__negdf2);
270+
FORCE_EXPORT_SYM(__negtf2);
271+
FORCE_EXPORT_SYM(__extendsfdf2);
272+
FORCE_EXPORT_SYM(__extendsftf2);
273+
FORCE_EXPORT_SYM(__extenddftf2);
274+
FORCE_EXPORT_SYM(__trunctfdf2);
275+
FORCE_EXPORT_SYM(__trunctfsf2);
276+
FORCE_EXPORT_SYM(__truncdfsf2);
277+
FORCE_EXPORT_SYM(__fixsfsi);
278+
FORCE_EXPORT_SYM(__fixdfsi);
279+
FORCE_EXPORT_SYM(__fixtfsi);
280+
FORCE_EXPORT_SYM(__fixsfdi);
281+
FORCE_EXPORT_SYM(__fixdfdi);
282+
FORCE_EXPORT_SYM(__fixtfdi);
283+
FORCE_EXPORT_SYM(__fixunssfsi);
284+
FORCE_EXPORT_SYM(__fixunsdfsi);
285+
FORCE_EXPORT_SYM(__fixunstfsi);
286+
FORCE_EXPORT_SYM(__fixunssfdi);
287+
FORCE_EXPORT_SYM(__fixunsdfdi);
288+
FORCE_EXPORT_SYM(__fixunstfdi);
289+
FORCE_EXPORT_SYM(__floatsisf);
290+
FORCE_EXPORT_SYM(__floatsidf);
291+
FORCE_EXPORT_SYM(__floatsitf);
292+
FORCE_EXPORT_SYM(__floatdisf);
293+
FORCE_EXPORT_SYM(__floatdidf);
294+
FORCE_EXPORT_SYM(__floatditf);
295+
FORCE_EXPORT_SYM(__floatunsisf);
296+
FORCE_EXPORT_SYM(__floatunsidf);
297+
FORCE_EXPORT_SYM(__floatunsitf);
298+
FORCE_EXPORT_SYM(__unordsf2);
299+
FORCE_EXPORT_SYM(__unorddf2);
300+
FORCE_EXPORT_SYM(__unordtf2);
301+
FORCE_EXPORT_SYM(__eqsf2);
302+
FORCE_EXPORT_SYM(__eqdf2);
303+
FORCE_EXPORT_SYM(__eqtf2);
304+
FORCE_EXPORT_SYM(__nesf2);
305+
FORCE_EXPORT_SYM(__nedf2);
306+
FORCE_EXPORT_SYM(__netf2);
307+
FORCE_EXPORT_SYM(__gesf2);
308+
FORCE_EXPORT_SYM(__gedf2);
309+
FORCE_EXPORT_SYM(__getf2);
310+
FORCE_EXPORT_SYM(__ltsf2);
311+
FORCE_EXPORT_SYM(__ltdf2);
312+
FORCE_EXPORT_SYM(__lttf2);
313+
FORCE_EXPORT_SYM(__lesf2);
314+
FORCE_EXPORT_SYM(__ledf2);
315+
FORCE_EXPORT_SYM(__letf2);
316+
FORCE_EXPORT_SYM(__gtsf2);
317+
FORCE_EXPORT_SYM(__gtdf2);
318+
FORCE_EXPORT_SYM(__gttf2);
319+
FORCE_EXPORT_SYM(__powisf2);
320+
FORCE_EXPORT_SYM(__powidf2);
321+
FORCE_EXPORT_SYM(__powitf2);
322+
323+
extern _Complex float __mulsc3(float, float, float, float);
324+
EXPORT_SYMBOL(__mulsc3);
325+
326+
extern _Complex __muldc3(double, double, double, double);
327+
EXPORT_SYMBOL(__muldc3);
328+
329+
extern _Complex long double __multc3(long double, long double, long double, long double);
330+
EXPORT_SYMBOL(__multc3);
331+
332+
extern _Complex float __divsc3(float, float, float, float);
333+
EXPORT_SYMBOL(__divsc3);
334+
335+
extern _Complex __divdc3(double, double, double, double);
336+
EXPORT_SYMBOL(__divdc3);
337+
338+
extern _Complex long double __divtc3(long double, long double, long double, long double);
339+
EXPORT_SYMBOL(__divtc3);
340+
341+
FORCE_EXPORT_SYM(__ashldi3);
342+
FORCE_EXPORT_SYM(__ashrdi3);
343+
FORCE_EXPORT_SYM(__divsi3);
344+
FORCE_EXPORT_SYM(__divdi3);
345+
FORCE_EXPORT_SYM(__lshrdi3);
346+
FORCE_EXPORT_SYM(__modsi3);
347+
FORCE_EXPORT_SYM(__moddi3);
348+
FORCE_EXPORT_SYM(__mulsi3);
349+
FORCE_EXPORT_SYM(__muldi3);
350+
FORCE_EXPORT_SYM(__negdi2);
351+
FORCE_EXPORT_SYM(__udivsi3);
256352
FORCE_EXPORT_SYM(__udivdi3);
353+
FORCE_EXPORT_SYM(__udivmoddi4);
354+
FORCE_EXPORT_SYM(__umodsi3);
355+
FORCE_EXPORT_SYM(__umoddi3);
356+
FORCE_EXPORT_SYM(__cmpdi2);
357+
FORCE_EXPORT_SYM(__ucmpdi2);
358+
FORCE_EXPORT_SYM(__absvsi2);
359+
FORCE_EXPORT_SYM(__absvdi2);
360+
FORCE_EXPORT_SYM(__addvsi3);
361+
FORCE_EXPORT_SYM(__addvdi3);
362+
FORCE_EXPORT_SYM(__mulvsi3);
363+
FORCE_EXPORT_SYM(__mulvdi3);
364+
FORCE_EXPORT_SYM(__negvsi2);
365+
FORCE_EXPORT_SYM(__negvdi2);
366+
FORCE_EXPORT_SYM(__subvsi3);
367+
FORCE_EXPORT_SYM(__subvdi3);
368+
FORCE_EXPORT_SYM(__clzsi2);
369+
FORCE_EXPORT_SYM(__clzdi2);
370+
FORCE_EXPORT_SYM(__ctzsi2);
371+
FORCE_EXPORT_SYM(__ctzdi2);
372+
FORCE_EXPORT_SYM(__ffsdi2);
373+
FORCE_EXPORT_SYM(__paritysi2);
374+
FORCE_EXPORT_SYM(__paritydi2);
375+
FORCE_EXPORT_SYM(__popcountsi2);
376+
FORCE_EXPORT_SYM(__popcountdi2);
377+
FORCE_EXPORT_SYM(__bswapsi2);
378+
FORCE_EXPORT_SYM(__bswapdi2);
257379
#endif
258380

259-
260-
261381
#if defined (CONFIG_CPP)
262382
FORCE_EXPORT_SYM(__cxa_pure_virtual);
263383
#endif

loader/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int loader(const struct shell *sh) {
138138
}
139139

140140
#if defined(CONFIG_LLEXT_STORAGE_WRITABLE)
141-
uint8_t *sketch_buf = k_aligned_alloc(4096, sketch_buf_len);
141+
uint8_t *sketch_buf = k_aligned_alloc(4, sketch_buf_len);
142142

143143
if (!sketch_buf) {
144144
printk("Unable to allocate %d bytes\n", sketch_buf_len);

loader/prj.conf

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
#
33
# This file contains selected Kconfig options for the application.
44

5-
CONFIG_USERSPACE=y
5+
CONFIG_USERSPACE=n
66
CONFIG_ARM_MPU=n
77

8-
CONFIG_LOG_DEFAULT_LEVEL=1
98
CONFIG_LOG=y
109

11-
CONFIG_HEAP_MEM_POOL_SIZE=32768
12-
CONFIG_MAIN_STACK_SIZE=32768
10+
CONFIG_HEAP_MEM_POOL_SIZE=50000
11+
CONFIG_MAIN_STACK_SIZE=8192
1312

1413
CONFIG_ARDUINO_API=y
1514

16-
CONFIG_SHELL=y
15+
CONFIG_SHELL=n
1716
CONFIG_SHELL_STACK_SIZE=2048
1817
CONFIG_SHELL_CMD_BUFF_SIZE=2048
1918
CONFIG_SHELL_LOG_LEVEL_DBG=y
2019

2120
CONFIG_LLEXT=y
22-
CONFIG_LLEXT_LOG_LEVEL_DBG=y
23-
CONFIG_LLEXT_HEAP_SIZE=32
24-
CONFIG_LLEXT_SHELL=y
21+
CONFIG_LLEXT_LOG_LEVEL_INF=y
22+
CONFIG_LLEXT_HEAP_SIZE=8
23+
CONFIG_LLEXT_SHELL=n
2524
CONFIG_LLEXT_STORAGE_WRITABLE=y
2625
CONFIG_LLEXT_EXPORT_DEVICES=y
2726

@@ -43,8 +42,7 @@ CONFIG_CPP=y
4342
CONFIG_STD_CPP17=y
4443
CONFIG_GLIBCXX_LIBCPP=y
4544
CONFIG_REQUIRES_FULL_LIBC=y
46-
CONFIG_PICOLIBC=y
47-
CONFIG_CBPRINTF_NANO=y
45+
CONFIG_CBPRINTF_COMPLETE=y
4846

4947
CONFIG_OUTPUT_DISASSEMBLY=y
5048
CONFIG_OUTPUT_SYMBOLS=y

loader/sysbuild/mcuboot.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CONFIG_MCUBOOT_LOG_LEVEL_DBG=y
2+
CONFIG_LOG_DEFAULT_LEVEL=4
3+
4+
#CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_START=0x1c020000
5+
#CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_SIZE=393216
6+
7+
CONFIG_I2C=n
8+
CONFIG_PM=n
9+
CONFIG_LOG_MODE_MINIMAL=n
10+
CONFIG_CONSOLE=y
11+
CONFIG_UART_CONSOLE=n
12+
CONFIG_MCUBOOT_SERIAL=y
13+
CONFIG_BOOT_SERIAL_UART=y
14+
CONFIG_BOOT_SERIAL_NO_APPLICATION=y
15+
CONFIG_MCUBOOT_INDICATION_LED=y
16+
#CONFIG_BOOT_SERIAL_WAIT_FOR_DFU=y
17+
#CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT=5000
18+
19+
CONFIG_OUTPUT_DISASSEMBLY=y
20+
CONFIG_OUTPUT_SYMBOLS=y

platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ compiler.warning_flags.all=-Wall -Wextra
1717

1818
compiler.path={build.compiler_path}
1919
compiler.c.cmd={build.crossprefix}gcc
20-
compiler.c.flags=-g -v -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -MMD -march={build.mcu}
20+
compiler.c.flags=-g -v -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -MMD -march={build.mcu} -mabi={build.abi}
2121
compiler.c.elf.cmd={build.crossprefix}g++
2222
compiler.c.elf.flags=-Wl,--gc-sections -march={build.mcu} -std=gnu++17
2323
compiler.S.cmd={build.crossprefix}g++
2424
compiler.S.flags=-c -x assembler-with-cpp -march={build.mcu}
2525
compiler.cpp.cmd={build.crossprefix}g++
26-
compiler.cpp.flags=-g -Os -std=gnu++17 -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cxxflags_file}" {compiler.zephyr.common_ldflags} {compiler.zephyr.extra_ldflags} {compiler.zephyr.common_cxxflags} {compiler.zephyr.extra_cxxflags} -MMD -march={build.mcu}
26+
compiler.cpp.flags=-g -Os -std=gnu++17 -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cxxflags_file}" {compiler.zephyr.common_ldflags} {compiler.zephyr.extra_ldflags} {compiler.zephyr.common_cxxflags} {compiler.zephyr.extra_cxxflags} -MMD -march={build.mcu} -mabi={build.abi}
2727
compiler.ar.cmd={build.crossprefix}ar
2828
compiler.ar.flags=rcs
2929
compiler.objcopy.cmd=

variants/poodleino-toy-v1_puppy_v2/poodleino-toy-v1_puppy_v2.overlay

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/ {
22
zephyr,user {
3-
builtin-led-gpios = <&gpio0 23 0>; //led3
4-
digital-pin-gpios = <&arduino_header 6 0>,
5-
<&arduino_header 7 0>,
6-
<&arduino_header 8 0>,
7-
<&arduino_header 9 0>,
8-
<&arduino_header 10 0>,
9-
<&arduino_header 11 0>,
10-
<&arduino_header 12 0>,
11-
<&arduino_header 13 0>,
12-
<&arduino_header 14 0>,
13-
<&arduino_header 15 0>,
14-
<&arduino_header 16 0>,
15-
<&arduino_header 17 0>,
16-
<&arduino_header 18 0>,
17-
<&arduino_header 19 0>,
18-
<&arduino_header 20 0>,
19-
<&arduino_header 21 0>;
3+
digital-pin-gpios = <&arduino_header 6 GPIO_ACTIVE_HIGH>,
4+
<&arduino_header 7 GPIO_ACTIVE_HIGH>,
5+
<&arduino_header 8 GPIO_ACTIVE_HIGH>,
6+
<&arduino_header 9 GPIO_ACTIVE_HIGH>,
7+
<&arduino_header 10 GPIO_ACTIVE_HIGH>,
8+
<&arduino_header 11 GPIO_ACTIVE_HIGH>,
9+
<&arduino_header 12 GPIO_ACTIVE_HIGH>,
10+
<&arduino_header 13 GPIO_ACTIVE_HIGH>,
11+
<&arduino_header 14 GPIO_ACTIVE_HIGH>,
12+
<&arduino_header 15 GPIO_ACTIVE_HIGH>,
13+
<&arduino_header 16 GPIO_ACTIVE_HIGH>,
14+
<&arduino_header 17 GPIO_ACTIVE_HIGH>,
15+
<&arduino_header 18 GPIO_ACTIVE_HIGH>,
16+
<&arduino_header 19 GPIO_ACTIVE_HIGH>,
17+
<&arduino_header 20 GPIO_ACTIVE_HIGH>,
18+
<&arduino_header 21 GPIO_ACTIVE_HIGH>,
19+
<&gpio0 23 GPIO_ACTIVE_HIGH>;
2020

2121
serials = <&uart0>;
2222
i2cs = <&i2c0>;

0 commit comments

Comments
 (0)