This commit is contained in:
Peter D. Gray 2023-12-11 12:02:24 -05:00
parent d330c09e60
commit 27ee8c90d5
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
9 changed files with 52 additions and 151 deletions

View File

@ -34,6 +34,7 @@ your key storage per-system unique.
- ``stm32l4x mass_erase 0`` in openocd monitor to bulk-erase whole chip
- To clear flash with write protect on... FLASH regs at 0x40022000 base
# XXX this process no longer works?
FLASH->CR = 0x40022014
FLASH->WRP1AR = 0x4002202c
@ -56,6 +57,18 @@ your key storage per-system unique.
# launch changes? (causes weird reset)
mww 0x40022014 0x8000000
- newer approach, with later OpenOCD versions:
# boot into DFU, gain control
halt
stm32l4x option_write 0 0x2c 0xff00ffff 0xffffffff
stm32l4x option_load 0
# (system resets, might run)
# check it worked
stm32l4x option_read 0 0x2c
# says: Option Register: <0x4002202c> = 0xff00ffff
- "stm32l4x.cpu mdb" is nice hexdump, much better than regular mdb
- If you're having trouble getting the debugger to started / link up right, try in DFU mode.

View File

@ -229,15 +229,14 @@ firewall_dispatch(int method_num, uint8_t *buf_io, int len_in,
#ifdef FOR_Q1_ONLY
if(arg2 == 3) {
// need some time to show OLED contents
// need some time for user to see message
delay_ms(100);
// pulse a one to TURN_OFF pin: PC0
turn_power_off();
}
#endif
if(arg2 == 2) {
// need some time to show OLED contents
// need some time for user to see message
delay_ms(100);
// reboot so we can "login" again

View File

@ -395,8 +395,7 @@ flash_save_bag_number(const uint8_t new_number[32])
flash_setup0();
flash_unlock();
// NOTE: can only write once! No provision for read/check, and write
// when non-ones will fail.
// NOTE: can only write once! No provision for read/check/update.
for(int i=0; i<(32/8); i++, dest+=8, src++) {
if(flash_burn(dest, *src)) {
INCONSISTENT("fail write");

View File

@ -8,7 +8,7 @@
# clobber - delete all build products
#
# any file it cant file, look in ../mk4-bootloader
# for any file it cant find, look in ../mk4-bootloader
VPATH = ../mk4-bootloader
# Toolchain

View File

@ -197,12 +197,12 @@ results = [
#( 'dfu', 'DFU', None, dict(text_pos=37) ), # removed
( 'downgrade', 'Downgrade?', 'history', {} ),
( 'corrupt', 'Firmware?', 'lemon', {} ),
( 'logout', 'Logout Done', 'logout', {}),
( 'poweroff', 'Power Off', 'power', {}),
( 'logout', 'Logout Done', 'logout', {'tight_mode': 1}),
( 'poweroff', 'Power Off', 'power', {'tight_mode': 1}),
( 'devmode', 'Danger! Custom!', 'bomb-spook', dict(icon_xpos=0)), # was 2
( 'red_light', 'Danger! Caution!', 'bomb-spook', dict(icon_xpos=0)), # was 2
( 'upgrading', 'Upgrading', 'graph-up', {}),
( 'replug', 'Power Cycle', None, {}), # visible in factory only
( 'upgrading', 'Upgrading', 'graph-up', { 'tight_mode': 1}),
( 'replug', 'SE1 Setup Done', None, {}), # visible in factory only
( 'search', 'Searching...', 'search-card', {}),
( 'recovery', 'Insert Card', 'insert-card', {}),
#( 'recovery', 'Recovery!', 'sdcard', {}),

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -149,18 +149,26 @@ gpio_setup(void)
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, 1); // turn on Backlight,
}
// GPU control: Port E: PE2=G_SWCLK_BOOT0, PE5=G_CTRL, PE6=G_RESET outputs
// GPU control: Port E: PE2=G_SWCLK_BOOT0=G_BUSY, PE5=G_CTRL, PE6=G_RESET
// - want open-drain on these outputs, so the SWD debugger can override
// - and PE2 needs to be pull-down input, because active high signal and
// GPU may not be running yet
{ GPIO_InitTypeDef setup = {
.Pin = GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_6,
.Pin = GPIO_PIN_5 | GPIO_PIN_6,
.Mode = GPIO_MODE_OUTPUT_OD,
.Pull = GPIO_PULLUP,
.Speed = GPIO_SPEED_FREQ_LOW,
};
HAL_GPIO_Init(GPIOE, &setup);
// G_BUSY: input, pull down
setup.Pin = GPIO_PIN_2;
setup.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOE, &setup);
// assert reset, leave others high
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2|GPIO_PIN_5, 1);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, 1);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, 0);
}

View File

@ -19,7 +19,7 @@
// LCD connections:
// - mostly on port A
// - all push/pull outputs
// - mostly push/pull outputs
// - shared with GPU
//
#define RESET_PIN GPIO_PIN_6
@ -31,6 +31,10 @@
// port B
#define TEAR_PIN GPIO_PIN_11
// port E - GPU connections
#define G_BUSY GPIO_PIN_2
#define G_CTRL GPIO_PIN_6
const int LCD_WIDTH = 320;
const int LCD_HEIGHT = 240;
const int NUM_PIXELS = (LCD_WIDTH*LCD_HEIGHT);
@ -55,15 +59,6 @@ memset2(uint16_t *dest, uint16_t value, uint16_t byte_len)
}
}
/*
// Bytes to send before sending the 1024 bytes of pixel data.
//
static const uint8_t before_show[] = {
0x21, 0x00, 0x7f, // setup column address range (start, end): 0-127
0x22, 0x00, 0x07 // setup page start/end address: 0 - 7
};
*/
#ifndef DISABLE_LCD
static SPI_HandleTypeDef spi_port;
#endif
@ -201,7 +196,12 @@ oled_setup(void)
// take over from GPU
// - can be issue when coming in via callgate from mpy which might have been showing menu
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, 1); // G_CTRL pin -- we have control
HAL_GPIO_WritePin(GPIOE, G_CTRL, 1); // set G_CTRL pin -- we have control
// .. wait for GPU to finish it's work
for(int i=0; i<100000; i++) {
if(HAL_GPIO_ReadPin(GPIOE, G_BUSY) == 0) break;
}
// Simple pins
// - must be opendrain to allow GPU to share
@ -481,131 +481,13 @@ oled_show_progress(const uint8_t *pixels, int progress)
rng_delay();
}
#if 0
// oled_busy_bar()
//
void
oled_busy_bar(bool en)
{
// Render a continuous activity (not progress) bar in lower 8 lines of display
// - using OLED itself to do the animation, so smooth and CPU free
// - cannot preserve bottom 8 lines, since we have to destructively write there
lcd_spi_setup();
static const uint8_t setup[] = {
//0x20, 0x00, // horz addr-ing mode (normal)
0x21, 0x00, 0x7f, // setup column address range (start, end): 0-127
0x22, 7, 7, // setup page start/end address: page 7=last 8 lines
};
static const uint8_t animate[] = {
0x2e, // stop animations in progress
0x26, // scroll leftwards (stock ticker mode)
0, // placeholder
7, // start 'page' (vertical)
7, // scroll speed: 7=fastest,
7, // end 'page'
0, 0xff, // placeholders
0x2f // start
};
static const uint8_t cleanup[] = {
0x2e, // stop animation
0x20, 0x00, // horz addr-ing mode
0x21, 0x00, 0x7f, // setup column address range (start, end): 0-127
0x22, 7, 7, // setup page start/end address: page 7=last 8 lines
};
uint8_t data[128];
if(!en) {
// clear it, stop animation
memset(data, 0, sizeof(data));
lcd_write_cmd_sequence(sizeof(cleanup), cleanup);
lcd_write_data(sizeof(data), data);
return;
}
// some diagonal lines
for(int x=0; x<128; x++) {
// each byte here is a vertical column, 8 pixels tall, MSB at bottom
switch(x % 4) {
default:
data[x] = 0x0;
break;
case 0 ... 1:
data[x] = 0x80;
break;
}
}
lcd_write_cmd_sequence(sizeof(setup), setup);
lcd_write_data(sizeof(data), data);
lcd_write_cmd_sequence(sizeof(animate), animate);
}
// oled_draw_bar()
//
void
oled_draw_bar(int percent)
{
// Render a continuous activity (progress) bar in lower 8 lines of display
// - cannot preserve bottom 8 lines, since we have to destructively write there
// - requires OLED and GPIO's already setup by other code.
lcd_spi_setup();
static const uint8_t setup[] = {
0x21, 0x00, 0x7f, // setup column address range (start, end): 0-127
0x22, 7, 7, // setup page start/end address: page 7=last 8 lines
};
uint8_t data[128];
int cut = percent * 128 / 100;
// each byte here is a vertical column, 8 pixels tall, MSB at bottom
memset(data, 0x80, cut);
memset(data+cut, 0x0, 128-cut);
lcd_write_cmd_sequence(sizeof(setup), setup);
lcd_write_data(sizeof(data), data);
}
#endif
// oled_factory_busy()
//
void
oled_factory_busy(void)
{
/* XXX
// Render a continuous activity (not progress) bar in lower 8 lines of display
// - using OLED itself to do the animation, so smooth and CPU free
// - cannot preserve bottom 8 lines, since we have to destructively write there
//lcd_spi_setup();
static const uint8_t setup[] = {
0x21, 0x00, 0x7f, // setup column address range (start, end): 0-127
0x22, 7, 7, // setup page start/end address: page 7=last 8 lines
};
static const uint8_t animate[] = {
0x2e, // stop animations in progress
0x26, // scroll leftwards (stock ticker mode)
0, // placeholder
7, // start 'page' (vertical)
7, // scroll speed: 7=fastest,
7, // end 'page'
0, 0xff, // placeholders
0x2f // start
};
uint8_t data[128];
for(int x=0; x<128; x++) {
// each byte here is a vertical column, 8 pixels tall, MSB at bottom
data[x] = (1<<(7 - (x%8)));
}
lcd_write_cmd_sequence(sizeof(setup), setup);
lcd_write_data(sizeof(data), data);
lcd_write_cmd_sequence(sizeof(animate), animate);
*/
// not implemented: would need to talk to GPU for this
}
// EOF