microbit-foundation / standalone-error-program

A small, standalone (No CODAL) bit of code to display errors on the micro:bit, for use in DAPLink and as a template for BLE bootloader
MIT License
0 stars 1 forks source link

Standalone panic #2

Closed martinwork closed 4 years ago

martinwork commented 4 years ago

microbit_sapanic( code, iterations) displays an error code synchronously.

main() has a place marked with a magic word to poke the error code and number of iterations.

Bin is 2120 bytes. Hex is 6,016 bytes.

To build: cd "standalone-error-program/microbit/armgcc" make

Built bin and hex files are in standalone-error-program/microbit/armgcc/_build

A cut down nRF5SDK is included for convenience. Could probably use nrfx instead.

The linker file puts the bin at address 0. No need to merge softdevice or bootloader for testing.

jaustin commented 4 years ago

Thanks @martinwork that's quick!

We have a preference for using the nrfx repo as a submodule instead of adding the SDK, if that's possible please.

With things built the way you've done it, how large is the binary?

A few things I'd assumed but not stated:

Questions after a really quick pass :)

J

martinwork commented 4 years ago

Bin is 2120 bytes. Hex is 6,016 bytes.

This is basically using the nrfx from the SDK. I can experiment with the stand alone nrfx. The bootloader uses the SDK. I'm not sure exactly how to build it for DapLink's use. I was rather thinking the C source was the useful bit and the exact makefile and linker setup was just an example.

Here is a hex: nrf52833_xxaa.zip

A fork lets me backup online without inflicting my mistakes on the upstream!

MicroBitSAPanic vs MicroBitMiniDisplay

This is not a display driver. I was aiming at the simplest and smallest solution for DapLink to show a panic on the LEDs. Would you like me to create MicroBitMiniDisplay?

What's the meaning of c_ here?

"c" stands for constant. That was uppermost in my mind. Flash not RAM, I hope. A bit of an old-fashioned habit? Like the SDK uses "m"?

would pinmap_rows/cols make it more descriptive? And given the way we parametrise c_width and c_height https://github.com/martinwork/standalone-error-program/blob/standalone-panic/MicroBitSAPanic.c#L75 should those use the same parameters? At least we'll get compile time errors then if we change the size?

Absolutely! :) And there's a 4 there somewhere.

What are the downsides, if any, of roping in Pendolino over using static images for the 'letters'?

It's a bit untidy. I have just modified (and commented out most of) the MicroBitFont file, to get bitmaps for the digits and E, not included the whole of Pendolino. Are we safe to copy the relevant definitions without worrying about the original copyright on the file? For MicroBitMiniDisplay we would want all of Pendolino. Not sure what you mean by "static images". I was tempted to save 24 bytes by using definitions with 3 bytes instead of 5!

martinwork commented 4 years ago

Added macros for the constants. Added built bin and hex in the repo root. Code size (bytes): bin = 2092; hex = 5,934.

Change the error code... In the bin and hex, near the end, the 4 bytes after magic 53 41 45 50 (SAEP), contain the error code (2 bytes) and iterations (2 bytes), little endian.

martinwork commented 4 years ago

Added nrfx build. Code size (bytes): bin = 2080; hex = 5,910.

gerargz commented 4 years ago

Hi @martinwork , I've been testing the image and I have some feedback. I noticed that error codes with repeating digits may be hard to read. For example, error 022 could be wrongly interpreted as error code 02. Maybe clearing the display between digits for a small period of time could make it more readable.

Also, what does the 2 bytes for iterations do?

martinwork commented 4 years ago

Thanks @gerargz . There's a gap in there but a factor of about 100 too short! I'll experiment and push an update.

If iterations is 3, the message shows 3 times before a system reset. Iterations 0 means forever.

If this is not needed and the it should always loop forever, I can remove the iterations code and save a few bytes.

martinwork commented 4 years ago

@gerargz Here's a new version, with a blip between characters and without the iterations parameter. The bin is now 2036 bytes. I've included a hex with error 007.

built.zip