Kaynağa Gözat

Switch to a pared down arduino-pico framework

Switched to a custom branch of the arduino-pico framework that
has the proper compiled static libraries with the compile flags
changed to be compatible with the SCSI DaynaPORT emulator on
then ZuluSCSI Pico using a Pico W.

The Pico W on board LED blinks instead of the carrier board
LED in these cases:
 1) One long blink when the WiFi interface is initialized
 2) One short blink when a WiFi interface attempts to join a network
 3) Three short blinks when a network has successfully joined
J. Morio Sakaguchi 2 yıl önce
ebeveyn
işleme
5766225601

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

@@ -21,6 +21,7 @@
 #include "scsiPhy.h"
 #include "config.h"
 #include "network.h"
+#include <ZuluSCSI_platform_network.h>
 
 extern bool g_log_debug;
 
@@ -36,8 +37,6 @@ static uint16_t scsiNetworkPacketOutboundSizes[NETWORK_PACKET_QUEUE_SIZE];
 static uint8_t scsiNetworkPacketOutboundWriteIndex = 0;
 static uint8_t scsiNetworkPacketOutboundReadIndex = 0;
 
-struct __attribute__((packed)) wifi_network_entry wifi_network_list[WIFI_NETWORK_LIST_ENTRY_COUNT] = { 0 };
-
 static const uint32_t crc32_tab[] = {
 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
 	0xe963a535, 0x9e6495a3,	0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
@@ -425,7 +424,6 @@ int scsiNetworkCommand()
 	default:
 		handled = 0;
 	}
-
 	return handled;
 }
 

+ 0 - 21
lib/SCSI2SD/src/firmware/network.h

@@ -33,31 +33,10 @@ extern "C" {
 #define NETWORK_PACKET_QUEUE_SIZE   20		// must be <= 255
 #define NETWORK_PACKET_MAX_SIZE     1520
 
-struct __attribute__((packed)) wifi_network_entry {
-	char ssid[64];
-	char bssid[6];
-	int8_t rssi;
-	uint8_t channel;
-	uint8_t flags;
-	uint8_t _padding;
-#define WIFI_NETWORK_FLAGS_AUTH 0x1
-};
-#define WIFI_NETWORK_LIST_ENTRY_COUNT 10
-extern struct wifi_network_entry wifi_network_list[WIFI_NETWORK_LIST_ENTRY_COUNT];
-
-struct __attribute__((packed)) wifi_join_request {
-	char ssid[64];
-	char key[64];
-	uint8_t channel;
-	uint8_t _padding;
-};
-
 int scsiNetworkCommand(void);
 int scsiNetworkEnqueue(const uint8_t *buf, size_t len);
 int scsiNetworkPurge(void);
 
-extern int platform_network_send(uint8_t *buf, size_t len);
-
 #ifdef __cplusplus
 }
 #endif

+ 2 - 13
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform.h

@@ -25,6 +25,7 @@
 
 #include <stdint.h>
 #include <Arduino.h>
+#include "ZuluSCSI_platform_network.h"
 
 #ifdef ZULUSCSI_PICO
 // ZuluSCSI Pico carrier board variant
@@ -162,19 +163,7 @@ bool platform_write_romdrive(const uint8_t *data, uint32_t start, uint32_t count
 extern const uint16_t g_scsi_parity_lookup[256];
 extern const uint16_t g_scsi_parity_check_lookup[512];
 
-// Network functions
-bool platform_network_supported();
-void platform_network_poll();
-int platform_network_init(char *mac);
-void platform_network_add_multicast_address(uint8_t *mac);
-bool platform_network_wifi_join(char *ssid, char *password);
-int platform_network_wifi_start_scan();
-int platform_network_wifi_scan_finished();
-void platform_network_wifi_dump_scan_list();
-int platform_network_wifi_rssi();
-char * platform_network_wifi_ssid();
-char * platform_network_wifi_bssid();
-int platform_network_wifi_channel();
+
 
 #ifdef __cplusplus
 }

+ 30 - 19
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform_network.cpp

@@ -13,13 +13,11 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-
-#include "ZuluSCSI_platform.h"
+#ifdef ZULUSCSI_NETWORK
+#include "ZuluSCSI_platform_network.h"
 #include "ZuluSCSI_log.h"
 #include "ZuluSCSI_config.h"
 #include <scsi.h>
-
-#ifdef ZULUSCSI_NETWORK
 #include <network.h>
 
 extern "C" {
@@ -31,6 +29,14 @@ extern "C" {
 #define CYW43_IOCTL_GET_RSSI (0xfe)
 #endif
 
+#define PICO_W_GPIO_LED_PIN 0
+#define PICO_W_LED_ON() cyw43_arch_gpio_put(PICO_W_GPIO_LED_PIN, 1)
+#define PICO_W_LED_OFF() cyw43_arch_gpio_put(PICO_W_GPIO_LED_PIN, 0)
+#define PICO_W_LONG_BLINK_DELAY 200
+#define PICO_W_SHORT_BLINK_DELAY 75
+
+struct __attribute__((packed)) wifi_network_entry wifi_network_list[WIFI_NETWORK_LIST_ENTRY_COUNT] = { 0 };
+
 // A default DaynaPort-compatible MAC
 static const char defaultMAC[] = { 0x00, 0x80, 0x19, 0xc0, 0xff, 0xee };
 
@@ -55,12 +61,20 @@ int platform_network_init(char *mac)
 	if (!platform_network_supported())
 		return -1;
 
+	// long signal blink at network initialization
+	PICO_W_LED_OFF();
+	PICO_W_LED_ON();
+	delay(PICO_W_LONG_BLINK_DELAY);
+	PICO_W_LED_OFF();
+
+
 	logmsg(" ");
 	logmsg("=== Network Initialization ===");
 
 	memset(wifi_network_list, 0, sizeof(wifi_network_list));
 
 	cyw43_deinit(&cyw43_state);
+	cyw43_init(&cyw43_state);
 
 	if (mac == NULL || (mac[0] == 0 && mac[1] == 0 && mac[2] == 0 && mac[3] == 0 && mac[4] == 0 && mac[5] == 0))
 	{
@@ -92,7 +106,7 @@ int platform_network_init(char *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]);
 	if (memcmp(mac, read_mac, sizeof(read_mac)) != 0)
-		logmsg("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?",
+		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]);
 
 	network_in_use = true;
@@ -132,15 +146,12 @@ bool platform_network_wifi_join(char *ssid, char *password)
 	}
 	else
 	{
-		// Blink 2 times at start of connection sequence
-		LED_OFF();
-		for (uint8_t i = 0; i < 2; i++)
-		{
-			delay(75);
-			LED_ON();
-			delay(75);
-			LED_OFF();
-		}
+		// Short single blink at start of connection sequence
+		PICO_W_LED_OFF();
+		delay(PICO_W_SHORT_BLINK_DELAY);
+		PICO_W_LED_ON();
+		delay(PICO_W_SHORT_BLINK_DELAY);
+		PICO_W_LED_OFF();
 	}
 	
 	return (ret == 0);
@@ -328,13 +339,13 @@ void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf)
 	{
 		logmsg_f("Successfully connected to Wi-Fi SSID \"%s\"", ssid);
 		// blink LED 3 times when connected
-		LED_OFF();
+		PICO_W_LED_OFF();
 		for (uint8_t i = 0; i < 3; i++)
 		{
-			delay(75);
-			LED_ON();
-			delay(75);
-			LED_OFF();
+			delay(PICO_W_SHORT_BLINK_DELAY);
+			PICO_W_LED_ON();
+			delay(PICO_W_SHORT_BLINK_DELAY);
+			PICO_W_LED_OFF();
 		}
 	}
 }

+ 63 - 0
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform_network.h

@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2023 joshua stein <jcs@jcs.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#pragma once
+
+#ifdef ZULUSCSI_NETWORK
+
+#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct __attribute__((packed)) wifi_network_entry {
+	char ssid[64];
+	char bssid[6];
+	int8_t rssi;
+	uint8_t channel;
+	uint8_t flags;
+	uint8_t _padding;
+#define WIFI_NETWORK_FLAGS_AUTH 0x1
+};
+
+#define WIFI_NETWORK_LIST_ENTRY_COUNT 10
+extern struct wifi_network_entry wifi_network_list[WIFI_NETWORK_LIST_ENTRY_COUNT];
+
+struct __attribute__((packed)) wifi_join_request {
+	char ssid[64];
+	char key[64];
+	uint8_t channel;
+	uint8_t _padding;
+};
+
+bool platform_network_supported();
+void platform_network_poll();
+int platform_network_init(char *mac);
+void platform_network_add_multicast_address(uint8_t *mac);
+bool platform_network_wifi_join(char *ssid, char *password);
+int platform_network_wifi_start_scan();
+int platform_network_wifi_scan_finished();
+void platform_network_wifi_dump_scan_list();
+int platform_network_wifi_rssi();
+char * platform_network_wifi_ssid();
+char * platform_network_wifi_bssid();
+int platform_network_wifi_channel();
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif // ZULUSCSI_NETWORK

+ 7 - 2
platformio.ini

@@ -123,10 +123,12 @@ build_flags =
     -DUSE_ARDUINO=1
     -DZULUSCSI_PICO
 
+; Build for the ZuluSCSI Pico carrier board with a Pico-W
+; for SCSI DaynaPORT emulation
 [env:ZuluSCSI_Pico_Net_DaynaPORT]
 platform = https://github.com/maxgerhardt/platform-raspberrypi.git
 platform_packages = platformio/toolchain-gccarmnoneeabi@1.100301.220327
-    framework-arduinopico@https://github.com/BlueSCSI/arduino-pico-internal.git#e139b9c7816602597f473b3231032cca5d71a48a
+    framework-arduinopico@https://github.com/rabbitholecomputing/arduino-pico.git#v3.6.0-DaynaPORT
 framework = arduino
 board = rpipicow
 board_build.core = earlephilhower
@@ -148,7 +150,10 @@ build_flags =
     -DZULUSCSI_PICO
     -DZULUSCSI_NETWORK
     -DZULUSCSI_DAYNAPORT
-
+; 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
 
 ; Variant of RP2040 platform, based on Raspberry Pico board and a carrier PCB
 ; Differs in pinout from ZuluSCSI_RP2040 platform, but shares most of the code.