浏览代码

Get PlatformIO debug to work on RP2040 MCUs

Using the debug feature for PlatformIO now works. One caveat is
the debug code does not break on main. Execution must be paused
then it should break on custom breakpoints.
Morio 2 年之前
父节点
当前提交
d72012b3bc

+ 1 - 1
lib/ZuluSCSI_platform_RP2040/rp2040-daynaport.ld

@@ -21,7 +21,7 @@
 
 MEMORY
 {
-    FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 528k
+    FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 576k
     RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k  /* Leave space for pico-debug */
     SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
     SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k

+ 1 - 1
lib/ZuluSCSI_platform_RP2040/rp2040_btldr.ld

@@ -33,7 +33,7 @@
      * which comes as part of the main firmware.elf and is never overwritten.
      */
     FLASH(rx) : ORIGIN = 0x10000100, LENGTH = 128k-256
-    RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 240k  /* Leave space for pico-debug */
+    RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k  /* Leave space for pico-debug */
     SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
     SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
 }

+ 13 - 4
platformio.ini

@@ -91,6 +91,11 @@ lib_deps =
     ZuluSCSI_platform_RP2040
     SCSI2SD
     CUEParser
+debug_build_flags =
+    -O2 -ggdb -g3
+    ; The values can be adjusted down to get a debug build to fit to SRAM
+    -DLOGBUFSIZE=4096
+;    -DPREFETCH_BUFFER_SIZE=2048
 build_flags =
     -O2 -Isrc -ggdb -g3
     -Wall -Wno-sign-compare -Wno-ignored-qualifiers
@@ -136,6 +141,14 @@ extra_scripts = src/build_bootloader.py
 ldscript_bootloader = lib/ZuluSCSI_platform_RP2040/rp2040_btldr.ld
 board_build.ldscript = lib/ZuluSCSI_platform_RP2040/rp2040-daynaport.ld
 debug_tool = cmsis-dap
+debug_build_flags =
+    -O2 -ggdb -g3
+    ; The values can be adjusted down to get a debug build to fit to SRAM
+    -DLOGBUFSIZE=2048
+    -DPREFETCH_BUFFER_SIZE=2048
+    ; This controls the depth of 2 x NETWORK_PACKET_MAX_SIZE (1520 bytes)
+    ; For example a queue size of 10 would be 10 x 2 x 1520 = 30400 bytes
+    -DNETWORK_PACKET_QUEUE_SIZE=3
 lib_deps =
     SdFat=https://github.com/rabbitholecomputing/SdFat#2.2.0-gpt
     minIni
@@ -156,15 +169,11 @@ build_flags =
 ; These take a large portion of the SRAM and can be adjusted
 ; It is important to leave enough free space for USB serial to work
 ;   Around 7220 bytes seems to be enough.
-; The current settings use too much SRAM to debug the board over SWD
-; The values can be adjusted down to get a debug build to fit to SRAM
     -DLOGBUFSIZE=6144
     -DPREFETCH_BUFFER_SIZE=8192
     ; This controls the depth of 2 x NETWORK_PACKET_MAX_SIZE (1520 bytes)
     ; For example a queue size of 10 would be 10 x 2 x 1520 = 30400 bytes
     -DNETWORK_PACKET_QUEUE_SIZE=10
-
-
 ; build flags mirroring the framework-arduinopico#v3.6.0-DaynaPORT static library build
     -DPICO_CYW43_ARCH_POLL=1
 	-DCYW43_LWIP=0

+ 10 - 2
src/ZuluSCSI.cpp

@@ -373,11 +373,17 @@ bool findHDDImages()
       bool is_cd = (tolower(name[0]) == 'c' && tolower(name[1]) == 'd');
       bool is_fd = (tolower(name[0]) == 'f' && tolower(name[1]) == 'd');
       bool is_mo = (tolower(name[0]) == 'm' && tolower(name[1]) == 'o');
-      bool is_ne = (tolower(name[0]) == 'n' && tolower(name[1]) == 'e');
       bool is_re = (tolower(name[0]) == 'r' && tolower(name[1]) == 'e');
       bool is_tp = (tolower(name[0]) == 't' && tolower(name[1]) == 'p');
+#ifdef ZULUSCSI_NETWORK
+      bool is_ne = (tolower(name[0]) == 'n' && tolower(name[1]) == 'e');
+#endif // ZULUSCSI_NETWORK
 
-      if (is_hd || is_cd || is_fd || is_mo || is_ne || is_re || is_tp)
+      if (is_hd || is_cd || is_fd || is_mo || is_re || is_tp
+#ifdef ZULUSCSI_NETWORK
+        || is_ne
+#endif // ZULUSCSI_NETWORK
+      )
       {
         // Check if the image should be loaded to microcontroller flash ROM drive
         bool is_romdrive = false;
@@ -462,7 +468,9 @@ bool findHDDImages()
         if (is_cd) type = S2S_CFG_OPTICAL;
         if (is_fd) type = S2S_CFG_FLOPPY_14MB;
         if (is_mo) type = S2S_CFG_MO;
+#ifdef ZULUSCSI_NETWORK
         if (is_ne) type = S2S_CFG_NETWORK;
+#endif // ZULUSCSI_NETWORK
         if (is_re) type = S2S_CFG_REMOVEABLE;
         if (is_tp) type = S2S_CFG_SEQUENTIAL;
 

+ 2 - 0
src/ZuluSCSI_disk.cpp

@@ -426,11 +426,13 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
             logmsg("---- Configuring as magneto-optical based on image name");
             img.deviceType = S2S_CFG_MO;
         }
+#ifdef ZULUSCSI_NETWORK
         else if (type == S2S_CFG_NETWORK)
         {
             logmsg("---- Configuring as network based on image name");
             img.deviceType = S2S_CFG_NETWORK;
         }
+#endif // ZULUSCSI_NETWORK
         else if (type == S2S_CFG_REMOVEABLE)
         {
             logmsg("---- Configuring as removable drive based on image name");