diff --git a/sw/device/boot_rom/bootstrap.c b/sw/device/boot_rom/bootstrap.c index a5a0f1b8cd9a1..886af487cf438 100644 --- a/sw/device/boot_rom/bootstrap.c +++ b/sw/device/boot_rom/bootstrap.c @@ -15,17 +15,27 @@ extern uint32_t ot_logo[]; +// Fills in bit of the progress bar that needs filling for completed frame +// frame_num given total frames frame_total. +// +// Overfills to the left (as it should already have been filled by previous +// frame update) to simplify code. static void update_oled_progress(uint32_t frame_num, uint32_t frame_total) { - uint32_t cols_per_frame = OLED_BYTE_COLS * 4 / frame_total; + // Multiply by 256 to handle non-integer cols_per_frame + uint32_t cols_per_frame = (OLED_BYTE_COLS * 256) / frame_total; uint32_t end_cols; if (frame_num == frame_total - 1) { end_cols = OLED_BYTE_COLS; } else { - end_cols = ((frame_num + 1) * cols_per_frame) / 4; + end_cols = ((frame_num + 1) * cols_per_frame) / 256; } - uint32_t start_cols = ((frame_num * cols_per_frame) >> 4) << 2; + // Want to compute word_col aligned byte_col. + // * >> 8 gives us the byte_col + // * >> 2 gives us the word_col (combine to get >> 10) + // * << 2 gives us the byte_col again round down to word_col boundary + uint32_t start_cols = ((frame_num * cols_per_frame) >> 10) << 2; for (uint32_t col = start_cols; col < end_cols; col += 4) { uint32_t xor_mask; @@ -92,13 +102,14 @@ static int bootstrap_flash(void) { for (;;) { if (spid_bytes_available() >= sizeof(f)) { spid_read_nb(&f, sizeof(f)); - update_oled_progress(f.hdr.frame_num & 0xFFFF, f.hdr.frame_total); + uint32_t frame_total = (f.hdr.frame_num & 0x7FFF0000) >> 16; + update_oled_progress(f.hdr.frame_num & 0xFFFF, frame_total); uart_send_str("Processing frame no: "); uart_send_uint(f.hdr.frame_num, 32); uart_send_str(" exp no: "); uart_send_uint(expected_frame_no, 32); uart_send_str(" total no: "); - uart_send_uint(f.hdr.frame_total, 32); + uart_send_uint(frame_total, 32); uart_send_str("\r\n"); if (FRAME_NO(f.hdr.frame_num) == expected_frame_no) { diff --git a/sw/device/boot_rom/bootstrap_msgs.h b/sw/device/boot_rom/bootstrap_msgs.h index 59b0befe81d6d..cc62922e81d19 100644 --- a/sw/device/boot_rom/bootstrap_msgs.h +++ b/sw/device/boot_rom/bootstrap_msgs.h @@ -8,7 +8,7 @@ #define RAW_BUFFER_SIZE 1024 #define FRAME_EOF_MARKER 0x80000000 -#define FRAME_NO(k) ((k)&0xffffff) +#define FRAME_NO(k) ((k)&0xffff) typedef struct { /* SHA2 of the entire frame_t message starting at the |frame_num| offset. */ @@ -18,8 +18,6 @@ typedef struct { * FRAME_EOF_MARKER. */ uint32_t frame_num; - uint32_t frame_total; - /* 0-based flash offset where the frame should be written to. */ uint32_t flash_offset; } frame_hdr_t; diff --git a/sw/device/boot_rom/meson.build b/sw/device/boot_rom/meson.build index a0061b05b72d7..8e20880557e0c 100644 --- a/sw/device/boot_rom/meson.build +++ b/sw/device/boot_rom/meson.build @@ -40,7 +40,7 @@ boot_rom_elf = executable( sw_lib_spi_device, sw_lib_uart, sw_lib_log, - sw_lib_oled_display, + sw_lib_oled_display_nofont, ], ) diff --git a/sw/device/boot_rom/ot_logo.h b/sw/device/boot_rom/ot_logo.h index 1608f13b90322..1452e82609a64 100644 --- a/sw/device/boot_rom/ot_logo.h +++ b/sw/device/boot_rom/ot_logo.h @@ -20,8 +20,8 @@ uint32_t ot_logo[] = { 0x00000000, 0x00000000, 0x00000000, - 0xc0800000, - 0x00000080, + 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, @@ -33,9 +33,9 @@ uint32_t ot_logo[] = { 0x00000000, 0x00000000, 0x3f1c1c1c, - 0x07073f3f, - 0xe0e0e7e7, - 0x3f0707e7, + 0xf7073f3f, + 0xf0f0f7f7, + 0x3f07f7f7, 0x1c1c3f3f, 0x0000001c, 0x00000000, @@ -52,22 +52,22 @@ uint32_t ot_logo[] = { 0x00f01018, 0xfe181800, 0x181818fe, - 0xfbf90000, - 0x180000f9, - 0x18fefe18, - 0x00000018, - 0x18187870, - 0xf8701818, - 0x000000f8, - 0x1830f8f8, - 0xf0301818, - 0x000000e0, + 0xfbfb0000, + 0x18180000, + 0x1818fefe, + 0x70000000, + 0x18181878, + 0xf8f87018, + 0xf8000000, + 0x181830f8, + 0xe0f03018, + 0x00000000, 0x00000000, 0x00000000, 0x7e1c1c1c, - 0xf0f07e7e, - 0x030373f3, - 0xfef0f073, + 0xf7f07e7e, + 0x070777f7, + 0xfef0f777, 0x1c1c7e7e, 0x0000001c, 0x00000000, @@ -85,15 +85,15 @@ uint32_t ot_logo[] = { 0x07000000, 0x0c0c0c0f, 0x0f0f0000, - 0x0000000f, - 0x0c0f0700, - 0x00000c0c, + 0x00000000, 0x0c0c0f07, - 0x0f070c0c, - 0x0000000f, - 0x00000f0f, + 0x0700000c, + 0x0c0c0c0f, + 0x0f0f070c, 0x0f000000, 0x0000000f, + 0x0f0f0000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, @@ -126,5 +126,5 @@ uint32_t ot_logo[] = { 0x00000000, 0x00000000, 0x00000000, - 0x00000000 + 0x00000000, }; diff --git a/sw/device/examples/hello_world/hello_world.c b/sw/device/examples/hello_world/hello_world.c index 12b17422278de..bbefda174f940 100644 --- a/sw/device/examples/hello_world/hello_world.c +++ b/sw/device/examples/hello_world/hello_world.c @@ -70,8 +70,7 @@ int main(int argc, char **argv) { oled_clear(1); - oled_write_str("RISCV Compliance", 0, 0); - oled_write_str("I-MISALIGN_LDST", 2, 0); + oled_write_str("Hello, World!", 1, 0); oled_write_disp(); diff --git a/sw/host/spiflash/updater.cc b/sw/host/spiflash/updater.cc index d18037ecd003a..38489a2265770 100644 --- a/sw/host/spiflash/updater.cc +++ b/sw/host/spiflash/updater.cc @@ -34,9 +34,8 @@ uint32_t Populate(uint32_t frame_number, uint32_t code_offset, } // Populate header number, offset and hash. - f->hdr.frame_num = frame_number; + f->hdr.frame_num = (frame_number & 0xFFFF) | ((frame_total & 0xFFFF) << 16); f->hdr.offset = code_offset; - f->hdr.frame_total = frame_total; return copy_size; } @@ -45,7 +44,6 @@ void HashFrame(Frame *f) { SHA256_CTX sha256; SHA256_Init(&sha256); SHA256_Update(&sha256, &f->hdr.frame_num, sizeof(f->hdr.frame_num)); - SHA256_Update(&sha256, &f->hdr.frame_total, sizeof(f->hdr.frame_total)); SHA256_Update(&sha256, &f->hdr.offset, sizeof(f->hdr.offset)); SHA256_Update(&sha256, f->data, f->PayloadSize()); SHA256_Final(f->hdr.hash, &sha256); diff --git a/sw/host/spiflash/updater.h b/sw/host/spiflash/updater.h index 3e5759626c0a9..b74978ff7653d 100644 --- a/sw/host/spiflash/updater.h +++ b/sw/host/spiflash/updater.h @@ -31,8 +31,6 @@ struct Frame { // Frame number. Starting at 0. uint32_t frame_num; - uint32_t frame_total; - // Flash target offset. uint32_t offset; } hdr; diff --git a/toolchain.txt b/toolchain.txt index 4004d9afa4e68..cab816ef9d06c 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -53,23 +53,6 @@ has_function_printf = false # '-Wall', # '-Werror'] -c_args = [ - '-fvisibility=hidden', - '-g', - '-mabi=ilp32', - '-march=rv32imc', - '-mcmodel=medany', - '-nostartfiles', - '-nostdlib', - '-mtune=sifive-3-series', - '-falign-functions=16', - '-funroll-all-loops', - '-finline-functions', - '-falign-jumps=4', - '-O3', - '-static', - '-Wall', - '-Werror'] #c_args = [ # '-fvisibility=hidden', # '-g', @@ -78,10 +61,27 @@ c_args = [ # '-mcmodel=medany', # '-nostartfiles', # '-nostdlib', -# '-Os', +# '-mtune=sifive-3-series', +# '-falign-functions=16', +# '-funroll-all-loops', +# '-finline-functions', +# '-falign-jumps=4', +# '-O3', # '-static', # '-Wall', # '-Werror'] +c_args = [ + '-fvisibility=hidden', + '-g', + '-mabi=ilp32', + '-march=rv32imc', + '-mcmodel=medany', + '-nostartfiles', + '-nostdlib', + '-Os', + '-static', + '-Wall', + '-Werror'] c_link_args = ['-nostdlib'] [build_machine]