Kaynağa Gözat

Move RP2040 based projects to new framework

Moved all projects that were on the RP2040 framework that PlatformIO
built to the Max Gerhardt and Earle F. Philhower framework.
Morio 1 yıl önce
ebeveyn
işleme
6841dcee82

+ 44 - 29
boards/ZuluSCSI_RP2040.json

@@ -1,42 +1,57 @@
 {
-    "name": "ZuluSCSI RP2040",
-    "url": "https://github.com/ZuluSCSI/ZuluSCSI-firmware",
-    "vendor": "ZuluSCSI",
     "build": {
-        "core": "arduino",
-        "cpu": "cortex-m0plus",
-        "extra_flags": "-DARDUINO_ARCH_RP2040",
-        "f_cpu": "133000000L",
-        "hwids": [
+      "arduino": {
+        "earlephilhower": {
+          "boot2_source": "boot2_w25q080_2_padded_checksum.S",
+          "usb_vid": "0x2E8A",
+          "usb_pid": "0xF00A"
+        }
+      },
+      "core": "earlephilhower",
+      "cpu": "cortex-m0plus",
+      "extra_flags": "-D ARDUINO_RHC_ZULUSCSI_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500",
+      "f_cpu": "125000000L",
+      "hwids": [
         [
-            "0x2E8A",
-            "0x00C0"
-        ]
+          "0x2E8A",
+          "0x00C0"
         ],
-        "mcu": "rp2040",
-        "variant": "RASPBERRY_PI_PICO"
+        [
+          "0x2E8A",
+          "0xF00A"
+        ]
+      ],
+      "mcu": "rp2040",
+      "variant": "zuluscsi_rp2040"
     },
     "debug": {
-        "jlink_device": "RP2040_M0_0",
-        "openocd_target": "rp2040.cfg",
-        "svd_path": "rp2040.svd"
+      "jlink_device": "RP2040_M0_0",
+      "openocd_target": "rp2040.cfg",
+      "svd_path": "rp2040.svd"
     },
     "frameworks": [
-        "arduino"
+      "arduino"
     ],
+    "name": "ZuluSCSI",
     "upload": {
-        "maximum_ram_size": 270336,
-        "maximum_size": 2097152,
-        "require_upload_port": true,
-        "native_usb": true,
-        "use_1200bps_touch": true,
-        "wait_for_upload_port": false,
-        "protocol": "picotool",
-        "protocols": [
+      "maximum_ram_size": 270336,
+      "maximum_size": 2097152,
+      "require_upload_port": true,
+      "native_usb": true,
+      "use_1200bps_touch": true,
+      "wait_for_upload_port": false,
+      "protocol": "picotool",
+      "protocols": [
+        "blackmagic",
         "cmsis-dap",
         "jlink",
         "raspberrypi-swd",
-        "picotool"
-        ]
-    }
-}
+        "picotool",
+        "picoprobe",
+        "pico-debug"
+      ]
+    },
+    "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
+    "vendor": "Rabbit Hole Computing"
+  }
+  

+ 13 - 5
lib/SCSI2SD/src/firmware/log.h

@@ -23,6 +23,7 @@
 extern "C" {
 #endif
 
+#ifdef NETWORK_DEBUG_LOGGING
 extern bool g_log_debug;
 
 extern void logmsg_buf(const unsigned char *buf, unsigned long size);
@@ -31,12 +32,19 @@ extern void logmsg_f(const char *format, ...);
 extern void dbgmsg_buf(const unsigned char *buf, unsigned long size);
 extern void dbgmsg_f(const char *format, ...);
 
-// check if debug is enabled before calling the logging function
-#define DBGMSG_BUF(buf, size) \
-	if (g_log_debug) {dbgmsg_buf(buf, size);}
+#define DBGMSG_BUF(buf, size) dbgmsg_buf(buf, size)
+#define DBGMSG_F(format, ...) dbgmsg_f(format, __VA_ARGS__);
+#define LOGMSG_BUF(buf, size) logmsg_buf(buf, size)
+#define LOGMSG_F(format, ...) logmsg_f(format, __VA_ARGS__);
 
-#define DBGMSG_F(format, ...) \
-	if (g_log_debug) {dbgmsg_f(format, __VA_ARGS__);}
+#else
+
+#define DBGMSG_BUF(buf, size) // Empty
+#define DBGMSG_F(format, ...) // Empty
+#define LOGMSG_BUF(buf, size) // Empty
+#define LOGMSG_F(format, ...) // Empty
+
+#endif // NETWORK_DEBUG_LOGGING
 
 #ifdef __cplusplus
 }

+ 3 - 3
lib/SCSI2SD/src/firmware/network.c

@@ -138,7 +138,7 @@ int scsiNetworkCommand()
 			}
 			else if (psize + 6 > size)
 			{
-				logmsg_f("%s: packet size too big (%d)", __func__, psize);
+				LOGMSG_F("%s: packet size too big (%d)", __func__, psize);
 				psize = size - 6;
 			}
 
@@ -371,7 +371,7 @@ int scsiNetworkCommand()
 				int size = sizeof(struct wifi_network_entry) * nets;
 				if (size + 2 > sizeof(scsiDev.data))
 				{
-					logmsg_f("WARNING: wifi_network_list is bigger than scsiDev.data, truncating");
+					LOGMSG_F("WARNING: wifi_network_list is bigger than scsiDev.data, truncating");
 					size = sizeof(scsiDev.data) - 2;
 					size -= (size % (sizeof(struct wifi_network_entry)));
 				}
@@ -420,7 +420,7 @@ int scsiNetworkCommand()
 			struct wifi_join_request req = { 0 };
 
 			if (size != sizeof(req)) {
-				logmsg_f("wifi_join_request bad size (%zu != %zu), ignoring", size, sizeof(req));
+				LOGMSG_F("wifi_join_request bad size (%zu != %zu), ignoring", size, sizeof(req));
 				scsiDev.status = CHECK_CONDITION;
 				scsiDev.phase = STATUS;
 				break;

+ 44 - 102
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform.cpp

@@ -37,23 +37,14 @@
 #include <hardware/structs/usb.h>
 #include "scsi_accel_target.h"
 
-#ifdef __MBED__
-#  include <platform/mbed_error.h>
-#endif // __MBED__
-
-#ifndef __MBED__
 #ifndef PIO_FRAMEWORK_ARDUINO_NO_USB
 # include <SerialUSB.h>
 # include <class/cdc/cdc_device.h>
 #endif
-#else
-# include <USB/PluggableUSBSerial.h>
-#endif // __MBED__
 
-#ifndef ZULUSCSI_NETWORK
-#  include <multicore.h>
-#else
-#  include <pico/multicore.h> 
+#include <pico/multicore.h>
+
+#ifdef ZULUSCSI_NETWORK
 extern "C" {
 #  include <pico/cyw43_arch.h>
 } 
@@ -70,10 +61,6 @@ static bool g_scsi_initiator = false;
 static uint32_t g_flash_chip_size = 0;
 static bool g_uart_initialized = false;
 
-#ifdef __MBED__
-void mbed_error_hook(const mbed_error_ctx * error_context);
-#endif // __MBED__
-
 /***************/
 /* GPIO init   */
 /***************/
@@ -225,9 +212,6 @@ void platform_init()
     g_uart_initialized = true;
 #endif // DISABLE_SWO
 
-#ifdef __MBED__
-    mbed_set_error_hook(mbed_error_hook);
-#endif // __MBED__
     logmsg("Platform: ", g_platform_name);
     logmsg("FW Version: ", g_log_firmwareversion);
 
@@ -366,11 +350,10 @@ void platform_late_init()
         gpio_conf(SCSI_IN_ATN,    GPIO_FUNC_SIO, true, false, false, true, false);
         gpio_conf(SCSI_IN_RST,    GPIO_FUNC_SIO, true, false, false, true, false);
 
-#ifndef __MBED__
-# ifndef PIO_FRAMEWORK_ARDUINO_NO_USB
+#ifndef PIO_FRAMEWORK_ARDUINO_NO_USB
     Serial.begin();
-# endif
-#endif // __MBED__
+#endif
+
 
 #ifdef ENABLE_AUDIO_OUTPUT
         // one-time control setup for DMA channels and second core
@@ -424,7 +407,6 @@ extern uint32_t __StackTop;
 void platform_emergency_log_save()
 {
     platform_set_sd_callback(NULL, NULL);
-
     SD.begin(SD_CONFIG_CRASH);
     FsFile crashfile = SD.open(CRASHFILE, O_WRONLY | O_CREAT | O_TRUNC);
 
@@ -444,21 +426,31 @@ void platform_emergency_log_save()
     crashfile.close();
 }
 
-#ifdef __MBED__
-void mbed_error_hook(const mbed_error_ctx * error_context)
+
+static void usb_log_poll();
+
+__attribute__((noinline))
+void show_hardfault(uint32_t *sp)
 {
+    uint32_t pc = sp[6];
+    uint32_t lr = sp[5];
+
     logmsg("--------------");
     logmsg("CRASH!");
     logmsg("Platform: ", g_platform_name);
     logmsg("FW Version: ", g_log_firmwareversion);
-    logmsg("error_status: ", (uint32_t)error_context->error_status);
-    logmsg("error_address: ", error_context->error_address);
-    logmsg("error_value: ", error_context->error_value);
     logmsg("scsiDev.cdb: ", bytearray(scsiDev.cdb, 12));
     logmsg("scsiDev.phase: ", (int)scsiDev.phase);
-    scsi_accel_log_state();
+    logmsg("SP: ", (uint32_t)sp);
+    logmsg("PC: ", pc);
+    logmsg("LR: ", lr);
+    logmsg("R0: ", sp[0]);
+    logmsg("R1: ", sp[1]);
+    logmsg("R2: ", sp[2]);
+    logmsg("R3: ", sp[3]);
+
+    uint32_t *p = (uint32_t*)((uint32_t)sp & ~3);
 
-    uint32_t *p = (uint32_t*)((uint32_t)error_context->thread_current_sp & ~3);
     for (int i = 0; i < 8; i++)
     {
         if (p == &__StackTop) break; // End of stack
@@ -471,24 +463,33 @@ void mbed_error_hook(const mbed_error_ctx * error_context)
 
     while (1)
     {
+        usb_log_poll();
         // Flash the crash address on the LED
         // Short pulse means 0, long pulse means 1
-        int base_delay = 1000;
+        int base_delay = 500;
         for (int i = 31; i >= 0; i--)
         {
             LED_OFF();
-            for (int j = 0; j < base_delay; j++) delay_ns(100000);
+            for (int j = 0; j < base_delay; j++) busy_wait_ms(1);
 
-            int delay = (error_context->error_address & (1 << i)) ? (3 * base_delay) : base_delay;
+            int delay = (pc & (1 << i)) ? (3 * base_delay) : base_delay;
             LED_ON();
-            for (int j = 0; j < delay; j++) delay_ns(100000);
+            for (int j = 0; j < delay; j++) busy_wait_ms(1);
             LED_OFF();
         }
 
-        for (int j = 0; j < base_delay * 10; j++) delay_ns(100000);
+        for (int j = 0; j < base_delay * 10; j++) busy_wait_ms(1);
     }
 }
-#endif // __MBED__
+
+__attribute__((naked, interrupt))
+void isr_hardfault(void)
+{
+    // Copies stack pointer into first argument
+    asm("mrs r0, msp\n"
+        "bl show_hardfault": : : "r0");
+}
+
 
 /*****************************************/
 /* Debug logging and watchdog            */
@@ -505,9 +506,8 @@ void mbed_error_hook(const mbed_error_ctx * error_context)
 // but does not unnecessarily delay normal execution.
 static void usb_log_poll()
 {
+#ifndef PIO_FRAMEWORK_ARDUINO_NO_USB
     static uint32_t logpos = 0;
-#ifndef __MBED__
-# ifndef PIO_FRAMEWORK_ARDUINO_NO_USB
     if (Serial.availableForWrite())
     {
         // Retrieve pointer to log start and determine number of bytes available.
@@ -524,26 +524,7 @@ static void usb_log_poll()
         actual = Serial.write(data, len);
         logpos -= available - actual;
     }
-# endif // PIO_FRAMEWORK_ARDUINO_NO_USB
-#else
-    if (_SerialUSB.ready())
-    {
-        // Retrieve pointer to log start and determine number of bytes available.
-        uint32_t available = 0;
-        const char *data = log_get_buffer(&logpos, &available);
-
-        // Limit to CDC packet size
-        uint32_t len = available;
-        if (len == 0) return;
-        if (len > CDC_MAX_PACKET_SIZE) len = CDC_MAX_PACKET_SIZE;
-
-        // Update log position by the actual number of bytes sent
-        // If USB CDC buffer is full, this may be 0
-        uint32_t actual = 0;
-        _SerialUSB.send_nb((uint8_t*)data, len, &actual);
-        logpos -= available - actual;
-    }
-#endif // __MBED__
+#endif // PIO_FRAMEWORK_ARDUINO_NO_USB
 }
 
 
@@ -638,11 +619,8 @@ static void watchdog_callback(unsigned alarm_num)
             logmsg("scsiDev.phase: ", (int)scsiDev.phase);
             scsi_accel_log_state();
 
-#ifdef __MBED__
-            uint32_t *p =  (uint32_t*)__get_PSP();
-#else
             uint32_t *p =  (uint32_t*)__get_MSP();
-#endif
+
             for (int i = 0; i < 8; i++)
             {
             if (p == &__StackTop) break; // End of stack
@@ -665,11 +643,8 @@ static void watchdog_callback(unsigned alarm_num)
             logmsg("scsiDev.cdb: ", bytearray(scsiDev.cdb, 12));
             logmsg("scsiDev.phase: ", (int)scsiDev.phase);
 
-#ifdef __MBED__
-            uint32_t *p =  (uint32_t*)__get_PSP();
-#else
             uint32_t *p =  (uint32_t*)__get_MSP();
-#endif
+
             for (int i = 0; i < 8; i++)
             {
                 if (p == &__StackTop) break; // End of stack
@@ -786,15 +761,12 @@ bool platform_rewrite_flash_page(uint32_t offset, uint8_t buffer[PLATFORM_FLASH_
         }
     }
 
-
-#ifdef __MBED__
-    if (NVIC_GetEnableIRQ(USBCTRL_IRQn))
+    if (NVIC_GetEnableIRQ(USBCTRL_IRQ_IRQn))
     {
         logmsg("Disabling USB during firmware flashing");
-        NVIC_DisableIRQ(USBCTRL_IRQn);
+        NVIC_DisableIRQ(USBCTRL_IRQ_IRQn);
         usb_hw->main_ctrl = 0;
     }
-#endif // __MBED__
 
     dbgmsg("Writing flash at offset ", offset, " data ", bytearray(buffer, 4));
     assert(offset % PLATFORM_FLASH_PAGE_SIZE == 0);
@@ -1026,33 +998,3 @@ const uint16_t g_scsi_parity_check_lookup[512] __attribute__((aligned(1024), sec
 #undef X
 
 } /* extern "C" */
-
-
-#ifdef __MBED__
-/* Logging from mbed */
-
-static class LogTarget: public mbed::FileHandle {
-public:
-    virtual ssize_t read(void *buffer, size_t size) { return 0; }
-    virtual ssize_t write(const void *buffer, size_t size)
-    {
-        // A bit inefficient but mbed seems to write() one character
-        // at a time anyways.
-        for (int i = 0; i < size; i++)
-        {
-            char buf[2] = {((const char*)buffer)[i], 0};
-            log_raw(buf);
-        }
-        return size;
-    }
-
-    virtual off_t seek(off_t offset, int whence = SEEK_SET) { return offset; }
-    virtual int close() { return 0; }
-    virtual off_t size() { return 0; }
-} g_LogTarget;
-
-mbed::FileHandle *mbed::mbed_override_console(int fd)
-{
-    return &g_LogTarget;
-}
-#endif // __MBED__

+ 17 - 20
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform_network.cpp

@@ -82,9 +82,8 @@ int platform_network_init(char *mac)
 		// retain Dayna vendor but use a device id specific to this board
 		pico_get_unique_board_id(&board_id);
 		if (g_log_debug)
-			logmsg_f("Unique board id: %02x %02x %02x %02x  %02x %02x %02x %02x",
-				board_id.id[0], board_id.id[1], board_id.id[2], board_id.id[3],
-				board_id.id[4], board_id.id[5], board_id.id[6], board_id.id[7]);
+			logmsg("Unique board id: ", board_id.id[0], " ", board_id.id[1], " ", board_id.id[2], " ", board_id.id[3], " ", 
+										board_id.id[4], " ", board_id.id[5], " ", board_id.id[6], " ", board_id.id[7]);
 
 		if (board_id.id[3] != 0 && board_id.id[4] != 0 && board_id.id[5] != 0)
 		{
@@ -101,11 +100,11 @@ int platform_network_init(char *mac)
 	cyw43_arch_enable_sta_mode();
 
 	cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, read_mac);
-	logmsg_f("Wi-Fi MAC: %02X:%02X:%02X:%02X:%02X:%02X",
-		read_mac[0], read_mac[1], read_mac[2], read_mac[3], read_mac[4], read_mac[5]);
+	logmsg("Wi-Fi MAC: ", read_mac[0],":",read_mac[1], ":", read_mac[2], ":", read_mac[3], ":", read_mac[4], ":", read_mac[5]);
 	if (memcmp(mac, read_mac, sizeof(read_mac)) != 0)
-		logmsg_f("WARNING: Wi-Fi MAC is not what was requested (%02x:%02x:%02x:%02x:%02x:%02x), is libpico not compiled with CYW43_USE_OTP_MAC=0?",
-			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+		logmsg("WARNING: Wi-Fi MAC is not what was requested (", 
+				(uint8_t)mac[0], ":", (uint8_t)mac[1], ":", (uint8_t)mac[2], ":", (uint8_t)mac[3], ":", (uint8_t)mac[4], ":", (uint8_t)mac[5],
+				"), is libpico not compiled with CYW43_USE_OTP_MAC=0?");
 
 	network_in_use = true;
 
@@ -117,7 +116,7 @@ void platform_network_add_multicast_address(uint8_t *mac)
 	int ret;
 
 	if ((ret = cyw43_wifi_update_multicast_filter(&cyw43_state, mac, true)) != 0)
-		logmsg_f("%s: cyw43_wifi_update_multicast_filter: %d", __func__, ret);
+		logmsg( __func__, ": cyw43_wifi_update_multicast_filter: ", ret);
 }
 
 bool platform_network_wifi_join(char *ssid, char *password)
@@ -129,18 +128,18 @@ bool platform_network_wifi_join(char *ssid, char *password)
 
 	if (password == NULL || password[0] == 0)
 	{
-		logmsg_f("Connecting to Wi-Fi SSID \"%s\" with no authentication", ssid);
+		logmsg("Connecting to Wi-Fi SSID \"", ssid, "\" with no authentication");
 		ret = cyw43_arch_wifi_connect_async(ssid, NULL, CYW43_AUTH_OPEN);
 	}
 	else
 	{
-		logmsg_f("Connecting to Wi-Fi SSID \"%s\" with WPA/WPA2 PSK", ssid);
+		logmsg("Connecting to Wi-Fi SSID \"", ssid, "\" with WPA/WPA2 PSK");
 		ret = cyw43_arch_wifi_connect_async(ssid, password, CYW43_AUTH_WPA2_MIXED_PSK);
 	}
 
 	if (ret != 0)
 	{
-		logmsg_f("Wi-Fi connection failed: %d", ret);
+		logmsg("Wi-Fi connection failed: ", ret);
 	}
 	else
 	{
@@ -168,7 +167,7 @@ int platform_network_send(uint8_t *buf, size_t len)
 {
 	int ret = cyw43_send_ethernet(&cyw43_state, 0, len, buf, 0);
 	if (ret != 0)
-		logmsg_f("cyw43_send_ethernet failed: %d", ret);
+		logmsg("cyw43_send_ethernet failed: ", ret);
 
 	return ret;
 }
@@ -257,11 +256,9 @@ void platform_network_wifi_dump_scan_list()
 		if (entry->ssid[0] == '\0')
 			break;
 			
-		logmsg_f("wifi[%d] = %s, channel %d, rssi %d, bssid %02x:%02x:%02x:%02x:%02x:%02x, flags %d",
-			i, entry->ssid, entry->channel, entry->rssi,
-			entry->bssid[0], entry->bssid[1], entry->bssid[2],
-			entry->bssid[3], entry->bssid[4], entry->bssid[5],
-			entry->flags);
+		logmsg("wifi[",i,"] = ",entry->ssid,", channel ",(int)entry->channel,", rssi ",(int)entry->rssi,
+				", bssid ",(uint8_t) entry->bssid[0],":",(uint8_t) entry->bssid[1],":",(uint8_t) entry->bssid[2],":",
+				(uint8_t) entry->bssid[3],":",(uint8_t) entry->bssid[4],":",(uint8_t) entry->bssid[5],", flags ", entry->flags);
 	}
 }
 
@@ -286,7 +283,7 @@ char * platform_network_wifi_ssid()
 	int ret = cyw43_ioctl(&cyw43_state, CYW43_IOCTL_GET_SSID, sizeof(ssid), (uint8_t *)&ssid, CYW43_ITF_STA);
 	if (ret)
 	{
-		logmsg_f("Failed getting Wi-Fi SSID: %d", ret);
+		logmsg("Failed getting Wi-Fi SSID: ", ret);
 		return NULL;
 	}
 
@@ -326,7 +323,7 @@ void cyw43_cb_process_ethernet(void *cb_data, int itf, size_t len, const uint8_t
 
 void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf)
 {
-	logmsg_f("Disassociated from Wi-Fi SSID \"%s\"", self->ap_ssid);
+	logmsg("Disassociated from Wi-Fi SSID \"",  (char *)self->ap_ssid,"\"");
 }
 
 void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf)
@@ -335,7 +332,7 @@ void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf)
 
 	if (ssid)
 	{
-		logmsg_f("Successfully connected to Wi-Fi SSID \"%s\"", ssid);
+		logmsg("Successfully connected to Wi-Fi SSID \"",ssid,"\"");
 		// blink LED 3 times when connected
 		PICO_W_LED_OFF();
 		for (uint8_t i = 0; i < 3; i++)

+ 1 - 6
lib/ZuluSCSI_platform_RP2040/scsi_accel_target.cpp

@@ -38,17 +38,12 @@
 #include <hardware/irq.h>
 #include <hardware/structs/iobank0.h>
 #include <hardware/sync.h>
+#include <pico/multicore.h>
 
 #ifdef ENABLE_AUDIO_OUTPUT
 #include <audio.h>
 #endif // ENABLE_AUDIO_OUTPUT
 
-#ifdef ZULUSCSI_NETWORK
-#include <pico/multicore.h>
-#else
-#include <multicore.h>
-#endif // ZULUSCSI_NETWORK
-
 #if defined(ZULUSCSI_PICO) || defined(ZULUSCSI_BS2)
 #include "scsi_accel_target_Pico.pio.h"
 #else

+ 4 - 1
lib/ZuluSCSI_platform_RP2040/sd_card_sdio.cpp

@@ -95,7 +95,10 @@ bool SdioCard::begin(SdioConfig sdioConfig)
     // Establish initial connection with the card
     for (int retries = 0; retries < 5; retries++)
     {
-        delayMicroseconds(1000);
+        // After a hard fault crash, delayMicroseconds hangs
+        // using busy_wait_us_32 instead
+        // delayMicroseconds(1000);
+        busy_wait_us_32(1000);
         reply = 0;
         rp2040_sdio_command_R1(CMD0, 0, NULL); // GO_IDLE_STATE
         status = rp2040_sdio_command_R1(CMD8, 0x1AA, &reply); // SEND_IF_COND

+ 32 - 8
platformio.ini

@@ -85,11 +85,13 @@ build_flags =
 
 ; ZuluSCSI RP2040 hardware platform, based on the Raspberry Pi foundation RP2040 microcontroller
 [env:ZuluSCSI_RP2040]
-platform = raspberrypi@1.9.0
+platform = https://github.com/maxgerhardt/platform-raspberrypi.git
+platform_packages =
+    framework-arduinopico@https://github.com/rabbitholecomputing/arduino-pico.git#v3.6.0-DaynaPORT
+board_build.core = earlephilhower
+board = zuluscsi_rp2040
 framework = arduino
-board = ZuluSCSI_RP2040
 extra_scripts = src/build_bootloader.py
-platform_packages = platformio/toolchain-gccarmnoneeabi@1.100301.220327
 board_build.ldscript = lib/ZuluSCSI_platform_RP2040/rp2040.ld
 ldscript_bootloader = lib/ZuluSCSI_platform_RP2040/rp2040_btldr.ld
 lib_deps =
@@ -98,11 +100,11 @@ lib_deps =
     ZuluSCSI_platform_RP2040
     SCSI2SD
     CUEParser
+debug_tool = cmsis-dap
 debug_build_flags =
     -O2 -ggdb -g3
 ; The values can be adjusted down to get a debug build to fit in to SRAM
     -DLOGBUFSIZE=4096
-    ; -DPREFETCH_BUFFER_SIZE=2048
 build_flags =
     -O2 -Isrc -ggdb -g3
     -Wall -Wno-sign-compare -Wno-ignored-qualifiers
@@ -111,7 +113,12 @@ build_flags =
     -DENABLE_DEDICATED_SPI=1
     -DHAS_SDIO_CLASS
     -DUSE_ARDUINO=1
+    -DPICO_FLASH_SPI_CLKDIV=2
     -DZULUSCSI_V2_0
+; build flags mirroring the framework-arduinopico#v3.6.0-DaynaPORT static library build
+    -DPICO_CYW43_ARCH_POLL=1
+	-DCYW43_LWIP=0
+	-DCYW43_USE_OTP_MAC=0
 
 ; ZuluSCSI RP2040 hardware platform, as above, but with audio output support enabled
 [env:ZuluSCSI_RP2040_Audio]
@@ -134,6 +141,10 @@ build_flags =
     -DHAS_SDIO_CLASS
     -DUSE_ARDUINO=1
     -DZULUSCSI_PICO
+; build flags mirroring the framework-arduinopico#v3.6.0-DaynaPORT static library build
+    -DPICO_CYW43_ARCH_POLL=1
+	-DCYW43_LWIP=0
+	-DCYW43_USE_OTP_MAC=0
 
 ; Build for the ZuluSCSI Pico carrier board with a Pico-W
 ; for SCSI DaynaPORT emulation
@@ -153,9 +164,12 @@ debug_build_flags =
     -DLOGBUFSIZE=4096
     -DPREFETCH_BUFFER_SIZE=0
     -DSCSI2SD_BUFFER_SIZE=57344
-    ; This controls the depth NETWORK_PACKET_MAX_SIZE (1520 bytes)
-    ; For example a queue size of 10 would be 10 x 1520 = 30400 bytes
+; This controls the depth NETWORK_PACKET_MAX_SIZE (1520 bytes)
+; For example a queue size of 10 would be 10 x 1520 = 30400 bytes
     -DNETWORK_PACKET_QUEUE_SIZE=10
+; This flag enables verbose logging of TCP/IP traffic and other information
+; it also takes up a bit of SRAM so it should be disabled with production code
+    -DNETWORK_DEBUG_LOGGING
 
 lib_deps =
     SdFat=https://github.com/rabbitholecomputing/SdFat#2.2.0-gpt
@@ -178,9 +192,14 @@ build_flags =
     -DLOGBUFSIZE=8192
     -DPREFETCH_BUFFER_SIZE=4608
     -DSCSI2SD_BUFFER_SIZE=57344
-    ; This controls the depth of NETWORK_PACKET_MAX_SIZE (1520 bytes)
-    ; For example a queue size of 10 would be 10 x 1520 = 15200 bytes
+; This controls the depth of NETWORK_PACKET_MAX_SIZE (1520 bytes)
+; For example a queue size of 10 would be 10 x 1520 = 15200 bytes
     -DNETWORK_PACKET_QUEUE_SIZE=18
+    
+; This flag enables verbose logging of TCP/IP traffic and other information
+; it also takes up a bit of SRAM so it should be disabled with production code
+    ;-DNETWORK_DEBUG_LOGGING
+
 ; build flags mirroring the framework-arduinopico#v3.6.0-DaynaPORT static library build
     -DPICO_CYW43_ARCH_POLL=1
 	-DCYW43_LWIP=0
@@ -200,7 +219,12 @@ build_flags =
     -DHAS_SDIO_CLASS
     -DUSE_ARDUINO=1
     -DZULUSCSI_BS2
+; build flags mirroring the framework-arduinopico#v3.6.0-DaynaPORT static library build
+    -DPICO_CYW43_ARCH_POLL=1
+	-DCYW43_LWIP=0
+	-DCYW43_USE_OTP_MAC=0
 
+    
 ; ZuluSCSI F4 hardware platform with GD32F450ZET6 CPU.
 [env:ZuluSCSIv1_4]
 platform = https://github.com/CommunityGD32Cores/platform-gd32.git

+ 1 - 1
src/ZuluSCSI_initiator.cpp

@@ -462,7 +462,7 @@ void scsiInitiatorMainLoop()
 
             if(g_initiator_state.bad_sector_count != 0)
             {
-                logmsg_f("NOTE: There were %d bad sectors that could not be read off this drive.", g_initiator_state.bad_sector_count);
+                logmsg("NOTE: There were ",  (int) g_initiator_state.bad_sector_count, " bad sectors that could not be read off this drive.");
             }
 
             if (!g_initiator_state.eject_when_done)

+ 2 - 2
src/ZuluSCSI_log.cpp

@@ -215,7 +215,7 @@ static void log_va(bool debug, const char *format, va_list ap)
         logmsg(shared_log_buf);
     }
 }
-
+#ifdef NETWORK_DEBUG_LOGGING
 void logmsg_f(const char *format, ...)
 {
     va_list ap;
@@ -267,5 +267,5 @@ void dbgmsg_buf(const unsigned char *buf, unsigned long size)
         return;
     log_hex_buf(buf, size, true);
 }
-
+#endif // NETWORK_DEBUG_LOGGING
 

+ 2 - 0
src/ZuluSCSI_log.h

@@ -102,6 +102,7 @@ inline void dbgmsg(Params... params)
     }
 }
 
+#ifdef NETWORK_DEBUG_LOGGING
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -120,4 +121,5 @@ void dbgmsg_f(const char *format, ...);
 
 #ifdef __cplusplus
 }
+#endif
 #endif