mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-01-25 14:56:25 -05:00
fw: Steady white led while waiting cmd; led off while loading app
Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
parent
7eb4d0304b
commit
4afdc1cd1f
@ -31,14 +31,15 @@ The USB stick can remain in the jig during repeated development,
|
|||||||
programming and testing cycles. The USB stick should then be connected
|
programming and testing cycles. The USB stick should then be connected
|
||||||
to the computer using the provided USB-C cable (use the USB-C-to-A
|
to the computer using the provided USB-C cable (use the USB-C-to-A
|
||||||
adapter if needed). The jig also has a cutout to allow touching where
|
adapter if needed). The jig also has a cutout to allow touching where
|
||||||
the touch sensor is located (next to the LED). Note that connecting
|
the touch sensor is located (next to the LED on the outer edge). Note
|
||||||
the USB stick to the computer is not required for programming it. Note
|
that connecting the USB stick to the computer is not required for
|
||||||
also that with this setup, to reset the USB stick back to firmware
|
programming it. Note also that with this setup, to reset the USB stick
|
||||||
mode after loading an app, you need to unplug both the USB cable to
|
back to firmware mode after loading an app, you need to unplug both
|
||||||
the stick and the one to the programmer. Alternatively, you can try
|
the USB cable to the stick and the one to the programmer.
|
||||||
the script in `../hw/application_fpga/tools/reset-tk1` which pokes at
|
Alternatively, you can try the script in
|
||||||
the TKey that's sitting in the jig, leaving it in firmware mode so
|
`../hw/application_fpga/tools/reset-tk1` which pokes at the TKey
|
||||||
that a new app can be loaded.
|
that's sitting in the jig, leaving it in firmware mode so that a new
|
||||||
|
app can be loaded.
|
||||||
|
|
||||||
On Linux, `lsusb` should list the connected programmer as `cafe:4004
|
On Linux, `lsusb` should list the connected programmer as `cafe:4004
|
||||||
Blinkinlabs ICE40 programmer`. If the USB stick is also connected it
|
Blinkinlabs ICE40 programmer`. If the USB stick is also connected it
|
||||||
@ -65,8 +66,8 @@ $ make prog_flash
|
|||||||
|
|
||||||
After programming, the TKey can be connected to your computer (use the
|
After programming, the TKey can be connected to your computer (use the
|
||||||
USB-C-to-A adapter if needed) and will boot the firmware. When boot
|
USB-C-to-A adapter if needed) and will boot the firmware. When boot
|
||||||
has completed it will start flashing the LED white. This indicates
|
has completed the LED will be steady white. This indicates that it is
|
||||||
that it is ready to receive and measure an app.
|
ready to receive and measure an app.
|
||||||
|
|
||||||
To try out an app, continue to the README.md the apps repo:
|
To try out an app, continue to the README.md the apps repo:
|
||||||
https://github.com/tillitis/tillitis-key1-apps#readme
|
https://github.com/tillitis/tillitis-key1-apps#readme
|
||||||
|
@ -29,7 +29,7 @@ sudo apt install build-essential clang lld llvm bison flex libreadline-dev \
|
|||||||
|
|
||||||
## Gateware: Yosys/Icestorm toolchain
|
## Gateware: Yosys/Icestorm toolchain
|
||||||
|
|
||||||
If the LED of your TKey is flashing white when you plug it, then the
|
If the LED of your TKey is steady white when you plug it, then the
|
||||||
firmware is running and it's already usable! If you want to develop
|
firmware is running and it's already usable! If you want to develop
|
||||||
TKey apps, then only the above general development environment is
|
TKey apps, then only the above general development environment is
|
||||||
needed.
|
needed.
|
||||||
|
@ -13,7 +13,7 @@ void forever_redflash()
|
|||||||
|
|
||||||
int led_on = 0;
|
int led_on = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
*led = led_on ? LED_RED : 0;
|
*led = led_on ? LED_RED : LED_BLACK;
|
||||||
for (volatile int i = 0; i < 800000; i++) {
|
for (volatile int i = 0; i < 800000; i++) {
|
||||||
}
|
}
|
||||||
led_on = !led_on;
|
led_on = !led_on;
|
||||||
|
@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
|
#define LED_BLACK 0
|
||||||
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
|
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
|
||||||
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
|
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
|
||||||
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
|
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
|
||||||
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
|
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
void forever_redflash();
|
void forever_redflash();
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,12 +234,8 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t in;
|
uint8_t in;
|
||||||
if (state == FW_STATE_LOADING) {
|
*led = (state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE;
|
||||||
*led = LED_WHITE;
|
|
||||||
in = readbyte();
|
in = readbyte();
|
||||||
} else {
|
|
||||||
in = readbyte_ledflash(LED_WHITE, 800000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseframe(in, &hdr) == -1) {
|
if (parseframe(in, &hdr) == -1) {
|
||||||
htif_puts("Couldn't parse header\n");
|
htif_puts("Couldn't parse header\n");
|
||||||
|
@ -13,7 +13,6 @@ static volatile uint32_t *can_rx = (volatile uint32_t *)TK1_MMIO_UART_RX_STATUS;
|
|||||||
static volatile uint32_t *rx = (volatile uint32_t *)TK1_MMIO_UART_RX_DATA;
|
static volatile uint32_t *rx = (volatile uint32_t *)TK1_MMIO_UART_RX_DATA;
|
||||||
static volatile uint32_t *can_tx = (volatile uint32_t *)TK1_MMIO_UART_TX_STATUS;
|
static volatile uint32_t *can_tx = (volatile uint32_t *)TK1_MMIO_UART_TX_STATUS;
|
||||||
static volatile uint32_t *tx = (volatile uint32_t *)TK1_MMIO_UART_TX_DATA;
|
static volatile uint32_t *tx = (volatile uint32_t *)TK1_MMIO_UART_TX_DATA;
|
||||||
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
uint8_t genhdr(uint8_t id, uint8_t endpoint, uint8_t status, enum cmdlen len)
|
uint8_t genhdr(uint8_t id, uint8_t endpoint, uint8_t status, enum cmdlen len)
|
||||||
@ -134,20 +133,6 @@ uint8_t readbyte()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t readbyte_ledflash(int ledvalue, int loopcount)
|
|
||||||
{
|
|
||||||
int led_on = 0;
|
|
||||||
for (;;) {
|
|
||||||
*led = led_on ? ledvalue : 0;
|
|
||||||
for (int i = 0; i < loopcount; i++) {
|
|
||||||
if (*can_rx) {
|
|
||||||
return *rx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
led_on = !led_on;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int read(uint8_t *buf, size_t bufsize, size_t nbytes)
|
int read(uint8_t *buf, size_t bufsize, size_t nbytes)
|
||||||
{
|
{
|
||||||
if (nbytes > bufsize) {
|
if (nbytes > bufsize) {
|
||||||
|
@ -56,7 +56,6 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf);
|
|||||||
void writebyte(uint8_t b);
|
void writebyte(uint8_t b);
|
||||||
void write(uint8_t *buf, size_t nbytes);
|
void write(uint8_t *buf, size_t nbytes);
|
||||||
uint8_t readbyte();
|
uint8_t readbyte();
|
||||||
uint8_t readbyte_ledflash(int ledvalue, int loopcount);
|
|
||||||
int read(uint8_t *buf, size_t bufsize, size_t nbytes);
|
int read(uint8_t *buf, size_t bufsize, size_t nbytes);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user