Author SHA1 Message Date
rehius 1c497e1f1e Update config.h 2024-09-03 17:19:16 +00:00
rehius 476dd2212e Update boot_detect.c 2024-09-03 17:19:07 +00:00
rehius 5c2cf01ac1 Update boot_detect.c 2024-09-01 14:50:07 +00:00
rehius f1078f48cb Update boot_detect.c 2024-09-01 14:36:07 +00:00
rehius e307c02199 Update config.h 2024-09-01 14:33:29 +00:00
rehius e2c0bcea68 Update boot_detect.c 2024-09-01 14:33:14 +00:00
rehius 4a8ab75e32 Update board_detect.c 2024-08-30 06:29:29 +00:00
rehius 4ee7662b27 Update build.yml 2024-08-30 06:23:49 +00:00
rehius c4fe34f6f2 Update config.h 2024-08-30 06:22:29 +00:00
rehius eb23f0e1cd Update misc.c 2024-08-30 06:22:09 +00:00
rehius 528a8f698f Update main.c 2024-08-30 06:21:05 +00:00
rehius d7f667bc61 Update board_detect.h 2024-08-30 06:19:17 +00:00
rehius acdcf88e51 Update board_detect.c 2024-08-30 06:18:45 +00:00
rehius 6530fd9fe5 Update config.h 2023-10-01 23:22:13 +00:00
rehius 4ea9a57859 Update emmc.pio 2023-10-01 23:11:48 +00:00
rehius 2a27fc3aca Update pio_upload.c 2023-10-01 23:11:07 +00:00
rehius e5a1dcdff8 Update config.h 2023-10-01 22:36:34 +00:00
rehius 262b897103 Update pio_upload.c 2023-10-01 22:36:12 +00:00
rehius d2fae0f934 Update main.c (#7)
back to 200mhz
remove SRAM powerdown, abal1000x says, it spoils sleep
2023-09-09 08:32:07 +00:00
9 changed files with 70 additions and 52 deletions

No files matched your search

+4 -4
View File
@@ -45,8 +45,8 @@ jobs:
- name: Build busk
run: |
# Backup and modify memmap_default.ld for busk build
cp $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld.bak
sed -i 's/RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k/RAM(rwx) : ORIGIN = 0x20038000, LENGTH = 32k/g' $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld
cp $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld.bak
sed -i 's/RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k/RAM(rwx) : ORIGIN = 0x20038000, LENGTH = 32k/g' $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld
mkdir -p $GITHUB_WORKSPACE/build/busk
cd $GITHUB_WORKSPACE/build/busk
cmake $GITHUB_WORKSPACE/busk
@@ -54,8 +54,8 @@ jobs:
make clean
cd $GITHUB_WORKSPACE
# Restore original memmap_default.ld from backup
rm -f $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld
mv $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld.bak $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld
rm -f $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld
mv $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld.bak $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld
- name: Build usk
run: |
+22 -9
View File
@@ -14,12 +14,13 @@ enum board_type {
BOARD_XO,
BOARD_IB,
BOARD_PI,
BOARD_SQ
BOARD_SQ,
BOARD_WT
};
enum board_type cur_board = BOARD_WS;
bool detect_by_pull_up(int frc_pin, int det_pin)
bool detect_by_pull(int frc_pin, int det_pin, bool up)
{
bool result = false;
if (frc_pin >= 0)
@@ -27,9 +28,9 @@ bool detect_by_pull_up(int frc_pin, int det_pin)
gpio_init(det_pin);
if (frc_pin >= 0)
gpio_set_dir(frc_pin, true);
gpio_pull_up(det_pin);
gpio_set_pulls(det_pin, up, !up);
sleep_us(15);
result = !gpio_get(det_pin);
result = gpio_get(det_pin) ^ up;
gpio_deinit(det_pin);
if (frc_pin >= 0)
gpio_deinit(frc_pin);
@@ -39,27 +40,32 @@ bool detect_by_pull_up(int frc_pin, int det_pin)
bool test_xiao()
{
return detect_by_pull_up(1, 2);
return detect_by_pull(1, 2, 1);
}
bool test_itsy()
{
return detect_by_pull_up(3, 2);
return detect_by_pull(3, 2, 1);
}
bool test_pico()
{
return detect_by_pull_up(-1, 22);
return detect_by_pull(-1, 22, 1);
}
bool test_ws()
{
return detect_by_pull_up(-1, 25);
return detect_by_pull(-1, 25, 1);
}
bool test_wt()
{
return detect_by_pull(-1, 16, 0);
}
bool test_sqc()
{
return detect_by_pull_up(-1, 17);
return detect_by_pull(-1, 17, 1);
}
void detect_board()
@@ -79,6 +85,8 @@ void detect_board()
cur_board = BOARD_PI;
} else if (test_sqc()) {
cur_board = BOARD_SQ;
} else if (test_wt()) {
cur_board = BOARD_WT;
} else {
cur_board = BOARD_WS;
}
@@ -160,3 +168,8 @@ bool is_pico()
{
return cur_board == BOARD_PI;
}
bool is_tiny()
{
return cur_board == BOARD_WT;
}
+3 -2
View File
@@ -1,11 +1,12 @@
#include "stdbool.h"
bool detect_by_pull_up(int frc_pin, int det_pin);
bool detect_by_pull(int frc_pin, int det_pin, bool up);
void detect_board();
int gli_pin();
int pwr_pin();
int led_pin();
bool is_pico();
bool is_tiny();
int scl_pin();
int sda_pin();
int sda_pin();
+15 -13
View File
@@ -20,12 +20,23 @@ bool wait_for_boot(int timeout_ms) {
bool was_cmd1 = false;
int reset_attempts = 0;
while(!time_reached(tio_full)) {
while(1) {
if (time_reached(tio_cmd1))
{
if (reset_attempts > 4)
{
halt_with_error(0, 3);
if (was_read_zero) {
halt_with_error(1, 3);
}
else if (tio_cmd1 != tio_full) {
halt_with_error(0, 3);
}
else if (was_cmd1) {
halt_with_error(2, 3);
} else {
halt_with_error(3, 3);
}
return false;
}
reset_attempts++;
reset_cpu();
@@ -45,7 +56,7 @@ bool wait_for_boot(int timeout_ms) {
}
else if (last_word == 0x51000000 && word == 0x0055) //read block 0
{
tio_full = make_timeout_time_ms(100);
tio_cmd1 = make_timeout_time_ms(400);
was_read_zero = true;
} else if (was_read_zero && last_word == 0x4D000200 && word == 0x00B1) // read status - erista only
{
@@ -58,13 +69,4 @@ bool wait_for_boot(int timeout_ms) {
last_word = word;
}
}
if (was_read_zero) {
halt_with_error(1, 3);
}
else if (was_cmd1) {
halt_with_error(2, 3);
} else {
halt_with_error(3, 3);
}
return false;
}
}
+4 -4
View File
@@ -1,10 +1,10 @@
#include "hardware/flash.h"
#define OFFSET_DIV 10
#define OFFSET_MIN 9200
#define OFFSET_MAX 10300
#define OFFSET_DIV 8
#define OFFSET_MIN 6200
#define OFFSET_MAX 6900
#define VER_HI 2
#define VER_LO 74
#define VER_LO 79
bool is_configured();
void init_config();
+3 -4
View File
@@ -58,11 +58,10 @@ read_loop:
.program glitch_dat_waiter
.wrap_target
mov x, y ; data length pre-loaded counter (512 + 16 - 1) * 8
wait_for_zero_filtered:
jmp pin, wait_for_zero_filtered
jmp pin, wait_for_zero_filtered
jmp pin, wait_for_zero_filtered
wait 0 pin, 0
wait_for_data_pack:
wait 0 pin, 30
wait 1 pin, 30
jmp x-- wait_for_data_pack
irq clear 1 ; 'data transfer done' trigger
.wrap
+10 -3
View File
@@ -21,10 +21,10 @@
bool write_payload();
// overclock to 300 MHz
// overclock to 200 MHz
void init_system() {
vreg_set_voltage(VREG_VOLTAGE_1_30);
set_sys_clock_khz(300000, true);
set_sys_clock_khz(200000, true);
}
// filled within "fast check" on eMMC init
@@ -94,13 +94,20 @@ int main()
init_fuses();
// LED & glitch & emmc PIO
upload_pio();
if (is_tiny())
{
gpio_put(led_pin(), 0);
sleep_us(100);
put_pixel(0);
sleep_us(100);
}
// check if this is the very first start
if (watchdog_caused_reboot() && boot_try == 0)
{
halt_with_error(1, 1);
}
// is chip reset required
bool force_button = detect_by_pull_up(1, 0);
bool force_button = detect_by_pull(1, 0, 1);
// start LED
put_pixel(PIX_blu);
// test pins
+8 -12
View File
@@ -23,23 +23,13 @@ extern int ws_pio_offset;
#define GPIO_IE PADS_BANK0_GPIO0_IE_BITS
#define GPIO_OD_PD (GPIO_OD | PADS_BANK0_GPIO0_PDE_BITS)
#define PTR_SAFE_RAM4 (void*)0x20040200
typedef void nopar();
void __not_in_flash_func(zzz)() {
static bool not_first = 0;
if(!not_first)
{
not_first = 1;
memcpy(PTR_SAFE_RAM4, (void*)((uint32_t)zzz - 1), 0x200);
((nopar*)(PTR_SAFE_RAM4 + 1))();
}
*(uint32_t*)(0x4000803C + 0x3000) = 1; // go to 12 MHz
uint32_t * vreg = (uint32_t*)0x40064000;
vreg[1] &= ~1; // disable brownout
*(uint32_t*)0x40060000 = 0x00d1e000; // disable rosc
*(uint32_t*)0x40004018 = 0xFF ^ (1 << 4); // disable SRAMs except ours
vreg[0] = 1; // lowest possible power
*(uint32_t*)0x40024000 = 0x00d1e000; // disable xosc
while(1);
@@ -62,7 +52,10 @@ void finish_pins_except_leds() {
}
void finish_pins_leds() {
gpio_disable_input_output(led_pin());
if (!is_tiny())
{
gpio_disable_input_output(led_pin());
}
gpio_disable_input_output(pwr_pin());
}
@@ -129,7 +122,10 @@ void put_pixel(uint32_t pixel_grb)
pio_sm_put_blocking(pio0, 3, pixel_grb << 8u);
sleep_us(50);
pio_sm_set_enabled(pio0, 3, false);
gpio_init(led_pin());
if (!is_tiny())
{
gpio_init(led_pin());
}
}
void gpio_disable_input_output(int pin)
+1 -1
View File
@@ -44,7 +44,7 @@ void upload_pio()
dsniff_pio_offset = pio_add_program(pio1, &glitch_dat_waiter_program);
pio1->sm[G_DAT0_SM].shiftctrl = c.shiftctrl;
// set y to amount of data ticks to skip
val = 528 * 300 / 25;
val = 527;
for (int i = 5; i >= 0; i--) {
pio_sm_exec(pio1, G_DAT0_SM, pio_encode_set(pio_y, (val >> i*4) & 15));
pio_sm_exec(pio1, G_DAT0_SM, pio_encode_in(pio_y, 4));