SD-Init-Fix (LVS/Samsung-T7-Micro-SD)
This commit is contained in:
1 parent
d3dca674aa
commit
bb9827f821
8 files changed
+1744
-1977
No files matched your search
+3
-1
@@ -20,11 +20,13 @@ add_executable(usk main.c board_detect.c fuses.c pio_upload.c boot_detect.c conf
|
|||||||
|
|
||||||
target_compile_definitions(usk PRIVATE PICO_NO_BINARY_INFO)
|
target_compile_definitions(usk PRIVATE PICO_NO_BINARY_INFO)
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/generated")
|
||||||
|
|
||||||
pico_generate_pio_header(usk ${CMAKE_CURRENT_LIST_DIR}/ws2812.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/generated)
|
pico_generate_pio_header(usk ${CMAKE_CURRENT_LIST_DIR}/ws2812.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/generated)
|
||||||
pico_generate_pio_header(usk ${CMAKE_CURRENT_LIST_DIR}/emmc.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/generated)
|
pico_generate_pio_header(usk ${CMAKE_CURRENT_LIST_DIR}/emmc.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/generated)
|
||||||
|
|
||||||
pico_set_program_name(usk "usk")
|
pico_set_program_name(usk "usk")
|
||||||
pico_set_program_version(usk "2.7")
|
pico_set_program_version(usk "3.00")
|
||||||
|
|
||||||
pico_set_binary_type(usk no_flash)
|
pico_set_binary_type(usk no_flash)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
# μsk
|
# Woody-NX μsk V3.00
|
||||||
|
|
||||||
|
Rehius-based RP2040 firmware with Woody-NX modifications: custom Picofly screen, battery indicator, S1/LVS integration, Samsung eMMC CMD1 adjustment, V3.00 version and brighter LEDs with red error codes. No PWM.
|
||||||
|
|
||||||
|
Original Rehius license retained. The prepared Switch loader and custom additions are embedded in payload.h; complete original Switch-loader core source is not part of this native firmware directory.
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
#define OFFSET_MIN 6200
|
#define OFFSET_MIN 6200
|
||||||
#define OFFSET_MAX 6900
|
#define OFFSET_MAX 6900
|
||||||
|
|
||||||
#define VER_HI 2
|
#define VER_HI 3
|
||||||
#define VER_LO 80
|
#define VER_LO 0
|
||||||
|
|
||||||
bool is_configured();
|
bool is_configured();
|
||||||
void init_config();
|
void init_config();
|
||||||
|
|||||||
@@ -59,38 +59,39 @@ void finish_pins_leds() {
|
|||||||
gpio_disable_input_output(pwr_pin());
|
gpio_disable_input_output(pwr_pin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void halt_with_error(uint32_t err, uint32_t bits)
|
void halt_with_error(uint32_t long_mask, uint32_t blinks)
|
||||||
{
|
{
|
||||||
finish_pins_except_leds();
|
finish_pins_except_leds();
|
||||||
pio_set_sm_mask_enabled(pio0, 0xF, false);
|
pio_set_sm_mask_enabled(pio0, 0xF, false);
|
||||||
pio_set_sm_mask_enabled(pio1, 0xF, false);
|
pio_set_sm_mask_enabled(pio1, 0xF, false);
|
||||||
set_sys_clock_khz(48000, true);
|
set_sys_clock_khz(48000, true);
|
||||||
vreg_set_voltage(VREG_VOLTAGE_0_95);
|
vreg_set_voltage(VREG_VOLTAGE_0_95);
|
||||||
if (bits != 1)
|
if (blinks != 1)
|
||||||
{
|
{
|
||||||
put_pixel(0);
|
put_pixel(0);
|
||||||
sleep_ms(PAUSE_BEFORE);
|
sleep_ms(PAUSE_BEFORE);
|
||||||
}
|
}
|
||||||
for(int j = 0; j < CODE_REPEATS; j++)
|
for(int j = 0; j < CODE_REPEATS; j++)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < bits; i++)
|
for(int i = 0; i < blinks; i++)
|
||||||
{
|
{
|
||||||
bool is_long = err & (1 << (bits - i - 1));
|
// Long mask in reverse.
|
||||||
|
bool is_long = long_mask & (1 << (blinks - i - 1));
|
||||||
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
|
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
|
||||||
bool success = bits == 1 && is_long == 0;
|
bool success = blinks == 1 && is_long == 0;
|
||||||
if (success)
|
if (blinks == 1)
|
||||||
put_pixel(PIX_whi);
|
put_pixel(PIX_whi);
|
||||||
else
|
else
|
||||||
put_pixel(PIX_yel);
|
put_pixel(0x004600); // GRB red; preserve native error blink timing
|
||||||
sleep_ms(is_long ? LONG_TIME : success ? SHORT_TIME * 2 : SHORT_TIME);
|
sleep_ms(is_long ? LONG_TIME : success ? SHORT_TIME * 2 : SHORT_TIME);
|
||||||
put_pixel(0);
|
put_pixel(0);
|
||||||
if (i != bits - 1 || j != CODE_REPEATS - 1)
|
if (i != blinks - 1 || j != CODE_REPEATS - 1)
|
||||||
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
|
sleep_ms(is_long ? LONG_PAUSE_TIME : SHORT_PAUSE_TIME);
|
||||||
if (i == bits - 1 && j != CODE_REPEATS - 1)
|
if (i == blinks - 1 && j != CODE_REPEATS - 1)
|
||||||
sleep_ms(PAUSE_BETWEEN);
|
sleep_ms(PAUSE_BETWEEN);
|
||||||
}
|
}
|
||||||
// first write case, do not repeat this kind of error code
|
// first write case, do not repeat this kind of error code
|
||||||
if (bits == 1)
|
if (blinks == 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
finish_pins_leds();
|
finish_pins_leds();
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#define PIX_blu 0x00003F
|
#define PIX_blu 0x0000D0
|
||||||
#define PIX_yel 0x151500
|
#define PIX_yel 0x383800
|
||||||
#define PIX_whi 0x111111
|
#define PIX_whi 0x383838
|
||||||
|
|
||||||
#define PIX_b 0x00000F
|
#define PIX_b 0x000015
|
||||||
|
|
||||||
void put_pixel(uint32_t pixel_grb);
|
void put_pixel(uint32_t pixel_grb);
|
||||||
|
|
||||||
void halt_with_error(uint32_t err, uint32_t bits);
|
void halt_with_error(uint32_t pause, uint32_t blinks);
|
||||||
|
|
||||||
void gpio_disable_input_output(int pin);
|
void gpio_disable_input_output(int pin);
|
||||||
|
|
||||||
@@ -14,4 +14,4 @@ void gpio_enable_input_output(int pin);
|
|||||||
|
|
||||||
void finish_pins_except_leds();
|
void finish_pins_except_leds();
|
||||||
|
|
||||||
void reset_cpu();
|
void reset_cpu();
|
||||||
@@ -393,7 +393,7 @@ bool init_op_cond() {
|
|||||||
simple_cmd_exec(MMC_GO_IDLE_STATE, 0);
|
simple_cmd_exec(MMC_GO_IDLE_STATE, 0);
|
||||||
if (!simple_cmd_exec_with_ret(MMC_SEND_OP_COND, 0, &res))
|
if (!simple_cmd_exec_with_ret(MMC_SEND_OP_COND, 0, &res))
|
||||||
return false;
|
return false;
|
||||||
int retry = 100;
|
int retry = 150;
|
||||||
while(--retry > 0) {
|
while(--retry > 0) {
|
||||||
if (!simple_cmd_exec_with_ret(MMC_SEND_OP_COND, SD_OCR_CCS | SD_OCR_VDD_18, &res))
|
if (!simple_cmd_exec_with_ret(MMC_SEND_OP_COND, SD_OCR_CCS | SD_OCR_VDD_18, &res))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+41
-41
@@ -1,42 +1,42 @@
|
|||||||
import struct, zlib
|
import struct, zlib
|
||||||
|
|
||||||
blocks = []
|
blocks = []
|
||||||
last_off = 0x10000000
|
last_off = 0x10000000
|
||||||
|
|
||||||
def add_block(data, offset):
|
def add_block(data, offset):
|
||||||
global last_off
|
global last_off
|
||||||
if last_off != offset:
|
if last_off != offset:
|
||||||
for i in range((offset - last_off) // 256):
|
for i in range((offset - last_off) // 256):
|
||||||
blocks.append((b"\xFF" * 256, last_off + i * 256))
|
blocks.append((b"\xFF" * 256, last_off + i * 256))
|
||||||
assert len(data) == 256
|
assert len(data) == 256
|
||||||
blocks.append((data, offset))
|
blocks.append((data, offset))
|
||||||
last_off = offset + 256
|
last_off = offset + 256
|
||||||
|
|
||||||
def get_uf2():
|
def get_uf2():
|
||||||
total_blocks = len(blocks)
|
total_blocks = len(blocks)
|
||||||
result = b""
|
result = b""
|
||||||
for n, b in enumerate(blocks):
|
for n, b in enumerate(blocks):
|
||||||
uf2 = struct.pack("<IIIIIIII", 0x0A324655, 0x9E5D5157, 0x00002000, b[1], 256, n, total_blocks, 0xe48bff56) + b[0] + b"\x00" * (476 - 256) + struct.pack("<I", 0x0AB16F30)
|
uf2 = struct.pack("<IIIIIIII", 0x0A324655, 0x9E5D5157, 0x00002000, b[1], 256, n, total_blocks, 0xe48bff56) + b[0] + b"\x00" * (476 - 256) + struct.pack("<I", 0x0AB16F30)
|
||||||
assert len(uf2) == 512
|
assert len(uf2) == 512
|
||||||
result += uf2
|
result += uf2
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def add_blocks(data, offset):
|
def add_blocks(data, offset):
|
||||||
if len(data) % 256:
|
if len(data) % 256:
|
||||||
data += b"\xFF" * (256 - len(data) % 256)
|
data += b"\xFF" * (256 - len(data) % 256)
|
||||||
for i in range(0, len(data), 256):
|
for i in range(0, len(data), 256):
|
||||||
add_block(data[i:i+256], offset + i)
|
add_block(data[i:i+256], offset + i)
|
||||||
|
|
||||||
add_blocks(open("../busk/busk.bin", "rb").read(), 0x10000000)
|
add_blocks(open("../busk/busk.bin", "rb").read(), 0x10000000)
|
||||||
|
|
||||||
add_blocks(b"\xFF" * 256, 0x10000000 + 0xFF00)
|
add_blocks(b"\xFF" * 256, 0x10000000 + 0xFF00)
|
||||||
|
|
||||||
fw = open("usk.bin", "rb").read()
|
fw = open("usk.bin", "rb").read()
|
||||||
fw = struct.pack("<II", len(fw), zlib.crc32(fw)) + fw
|
fw = struct.pack("<II", len(fw), zlib.crc32(fw)) + fw
|
||||||
open("update.bin", "wb").write(fw)
|
open("update.bin", "wb").write(fw)
|
||||||
|
|
||||||
fw = fw + b"\xFF" * (0x3)
|
fw = fw + b"\xFF" * (0x3)
|
||||||
|
|
||||||
add_blocks(fw, 0x10000000 + 0x10000)
|
add_blocks(fw, 0x10000000 + 0x10000)
|
||||||
|
|
||||||
open("firmware.uf2", "wb").write(get_uf2())
|
open("firmware.uf2", "wb").write(get_uf2())
|
||||||
Reference in new issue
Block a user