11
11
FRAMEWORK_DIR = platform .get_package_dir ("framework-picosdk" )
12
12
assert isdir (FRAMEWORK_DIR )
13
13
14
- mcu = "rp2350" if board .get ('build.mcu' ) == "rp2350" else "rp2040"
15
- is_rp2350 = mcu == "rp2350"
14
+ mcu = "rp2350" if "rp2350" in board .get ('build.mcu' ) else "rp2040"
15
+ is_rp2350 = mcu == "rp2350" # could be ARM or RISC-V
16
+ is_riscv = board .get ('build.mcu' ) == "rp2350-riscv"
16
17
rp2_variant_dir = join (FRAMEWORK_DIR , "src" , mcu )
17
18
header = "%s.h" % board .get ("build.variant" )
18
19
# try to find the board header in the common directory
@@ -58,11 +59,9 @@ def gen_config_autogen(target_base_dir, board_hdr):
58
59
#CFLAGS=sorted(list(cflags - ccflags)),
59
60
#CCFLAGS=sorted(list(ccflags)),
60
61
CPPDEFINES = [
61
- # BUG: defining PICO_RP2040 in any way will force compilation for 2040 only.
62
- # FIX: add RP2350 only if board requested was 2350
63
- ("PICO_RP2350" if board .get ('build.mcu' ) == "rp2350" else "PICO_RP2040" , 1 ),
64
- ("PICO_RISCV" , 0 ),
65
- ("PICO_ARM" , 1 ),
62
+ ("PICO_RP2350" if is_rp2350 else "PICO_RP2040" , 1 ),
63
+ ("PICO_RISCV" , int (is_riscv )),
64
+ ("PICO_ARM" , int (not is_riscv )),
66
65
("PICO_CMSIS_DEVICE" , "\" %s\" " % mcu .upper ()),
67
66
("PICO_DEFAULT_FLASH_SIZE_BYTES" , 2 * 1024 * 1024 ),
68
67
# default SDK defines for on-hardware build
@@ -112,6 +111,7 @@ def gen_config_autogen(target_base_dir, board_hdr):
112
111
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_exception" , "include" ),
113
112
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_flash" , "include" ),
114
113
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_gpio" , "include" ),
114
+ join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_hazard3" , "include" ),
115
115
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_i2c" , "include" ),
116
116
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_interp" , "include" ),
117
117
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_irq" , "include" ),
@@ -120,6 +120,8 @@ def gen_config_autogen(target_base_dir, board_hdr):
120
120
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_pwm" , "include" ),
121
121
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_resets" , "include" ),
122
122
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_rcp" , "include" ),
123
+ join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_riscv" , "include" ),
124
+ join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_riscv_platform_timer" , "include" ),
123
125
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_rtc" , "include" ),
124
126
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_spi" , "include" ),
125
127
join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_sync_spin_lock" , "include" ),
@@ -335,6 +337,11 @@ def configure_printf_impl():
335
337
# join("$BUILD_DIR", "PicoSDK"),
336
338
# join(FRAMEWORK_DIR, "src", "rp2_common", "cmsis", "stub", "CMSIS", "Device", "RP2040", "Source")
337
339
# )
340
+ if is_rp2350 :
341
+ pad_checksum_arch = "-a riscv" if is_riscv else "-a arm"
342
+ else :
343
+ # when calling into the RP2040 version of that script, it actually doesn't take a "-a" argument at all.
344
+ pad_checksum_arch = ""
338
345
339
346
gen_boot2_cmd = env .Command (
340
347
join ("$BUILD_DIR" , "boot2.S" ), # $TARGET
@@ -354,6 +361,7 @@ def configure_printf_impl():
354
361
"-I" , "$PROJECT_BUILD_DIR/$PIOENV/generated" ,
355
362
"-I\" %s\" " % join (rp2_variant_dir , "pico_platform" , "include" ),
356
363
"-I\" %s\" " % join (FRAMEWORK_DIR , "src" , "rp2_common" , "pico_platform_compiler" , "include" ),
364
+ "-I\" %s\" " % join (FRAMEWORK_DIR , "src" , "rp2_common" , "hardware_hazard3" , "include" ),
357
365
"-I\" %s\" " % join (rp2_variant_dir , "hardware_regs" , "include" ),
358
366
"-I\" %s\" " % join (FRAMEWORK_DIR , "src" , "rp2_common" , "pico_platform_common" , "include" ),
359
367
"-I\" %s\" " % join (FRAMEWORK_DIR , "src" , "rp2_common" , "pico_platform_sections" , "include" ),
@@ -374,6 +382,7 @@ def configure_printf_impl():
374
382
"$PYTHONEXE" ,
375
383
join (FRAMEWORK_DIR , "src" , mcu , "boot_stage2" , "pad_checksum" ),
376
384
"-s 0xffffffff" ,
385
+ pad_checksum_arch ,
377
386
join ("$BUILD_DIR" , "boot2.bin" ),
378
387
join ("$BUILD_DIR" , "boot2.S" ),
379
388
]), "Generating boot2 $BUILD_DIR/boot2.S" )
@@ -468,11 +477,11 @@ def configure_printf_impl():
468
477
src_filter
469
478
)
470
479
471
- # Will be crt0_riscv.S for RISC-V builds..
480
+ pico_crt0 = " crt0_riscv.S" if is_riscv else "crt0.S"
472
481
env .BuildSources (
473
482
join ("$BUILD_DIR" , "PicoSDKCRT0" ),
474
483
join (FRAMEWORK_DIR , "src" , "rp2_common" , "pico_crt0" ),
475
- "-<*> +<crt0.S>"
484
+ "-<*> +<%s>" % pico_crt0
476
485
)
477
486
478
487
default_common_components = [
0 commit comments