627 Commits

Author SHA1 Message Date
Mikael Ågren
3cd2f6c2b5
Merge b02c2d67d6450cd1bea6942d293a6f6ea8a607f1 into d2c7fb0ba9b0cb11791c94b38d17372899479d6a 2025-02-13 08:30:43 +00:00
Mikael Ågren
b02c2d67d6
PoC: fpga/tb: Allow access to syscall irq trigger area 2025-02-13 09:12:07 +01:00
Mikael Ågren
1968b3614c
PoC: tb: Check security monitor read access protection 2025-02-13 09:12:06 +01:00
Mikael Ågren
0cc991fea2
PoC: fpga: Revert back to 21 MHz
To avoid having to find a new nextpnr seed, for small changes, during
development
2025-02-12 17:23:26 +01:00
Mikael Ågren
d65e1eec4e
PoC: fpga: Update next-pnr seed to reach 24 MHz 2025-02-12 16:40:26 +01:00
Mikael Ågren
a68b646edf
PoC: testapp: Call reset syscall 2025-02-12 16:40:25 +01:00
Mikael Ågren
e4df068bb4
PoC: testapp: Call syscall accessing SPI flash 2025-02-12 16:40:25 +01:00
Mikael Ågren
e5e2ab2787
PoC: testfw: Check that SPI flash is available in firmware mode 2025-02-12 16:40:25 +01:00
Mikael Ågren
cbc7adf706
PoC: Integrate spi and flash code 2025-02-12 16:40:24 +01:00
Daniel Jobson
12c23cc149
PoC: fw: Import spi.[ch] and flash.[ch] 2025-02-12 16:40:24 +01:00
Mikael Ågren
b45489730a
PoC: testfw: Break out tests running in app mode into separate app
App mode can no longer be controlled from software. So the tests have to
run from firmware RAM.
2025-02-12 16:40:24 +01:00
Mikael Ågren
6c439b3a4f
PoC: testfw: Remove blake2s test
Removing the blake2s test since the possibility for the firmware to
expose a blake2s function to the app has been removed.
2025-02-12 16:40:23 +01:00
Mikael Ågren
f686c59e03
PoC: fw: Add experimental syscalls to firmware
Adds:
- SYSCALL_RESET
- SYSCALL_SET_LED
2025-02-12 16:40:23 +01:00
Mikael Ågren
1e959bebb6
PoC: tb: Expand existing tests with access checks in app mode and syscalls
Checks availability of:
- CDI
- UDI
- RAM
- SPI
2025-02-12 16:40:23 +01:00
Mikael Ågren
4a27940bf1
PoC: tb: Fix tb_tk1 test10 (SPI loop back test)
Fix test10. It broke while implementing interrupt based syscalls.

Cleaning up after the previous test. We reset the memory bus to a known
idle state. We also reset the DUT to make the SPI master visible.
2025-02-12 11:08:31 +01:00
Mikael Ågren
d07abc7ad2
PoC: tb: Fix tb_tk1 test5 (APP_START/APP_SIZE)
Fix test1. It broke while implementing interrupt based syscalls.

Instead of writing to ADDR_SYSTEM_MODE_CTRL, app mode is now entered
automatically when executing outside of ROM.
2025-02-12 11:08:31 +01:00
Mikael Ågren
fe16cc9f72
PoC: tb: Fix tb_tk1 test3 (CDI)
Fix test1. It broke while implementing interrupt based syscalls.

Instead of writing to ADDR_SYSTEM_MODE_CTRL, app mode is now entered
automatically when executing outside of ROM.
2025-02-12 11:08:30 +01:00
Mikael Ågren
e9f72a8530
PoC: tb: Add fetch instruction helper task to tb_tk1 2025-02-12 11:08:30 +01:00
Mikael Ågren
ed10222999
PoC: tb: Remove tb_tk1 blake2s test
Removing the blake2s test since the blake2s registers are removed.
2025-02-12 11:08:30 +01:00
Mikael Ågren
1179324f10
PoC: tb: Update tk1 test bench with new ports
Fixing tests that broke when adding interrupt based syscalls
2025-02-12 11:08:29 +01:00
Mikael Ågren
43239759e6
tb: Display errors in tb_tk1 even if DEBUG is 0
Always display errors to make them easy to find and troubleshoot.
2025-02-12 11:08:29 +01:00
Mikael Ågren
4532bec84d
PoC: tb: Write data only once per call to write_word() in tb_tk1
Keep WE and CS high for one clock cycle instead of two. To avoid writing
the same address twice.
2025-02-12 11:08:29 +01:00
Mikael Ågren
a9484d9cf4
PoC: Remove IRQ30 from fw/irqpoc_c_example
Removing IRQ30 since it us no longer exist
2025-02-12 11:08:28 +01:00
Mikael Ågren
91625c05bb
PoC: Remove IRQ30 from fw/irqpoc_with_app
Removing IRQ30 since it us no longer exist
2025-02-12 11:08:28 +01:00
Mikael Ågren
38b029f1c4
PoC: Remove IRQ30 from fw/irqpoc_led_toggle
Removing IRQ30 since it us no longer exist
2025-02-12 11:08:28 +01:00
Mikael Ågren
7f718b298b
PoC: Remove IRQ30 from fw/irqpoc
Removing IRQ30 since it us no longer exist
2025-02-12 11:08:27 +01:00
Daniel Jobson
833bf63bc8
PoC: Make sensitive assets only readable/writable before system_mode is set
After the first time system_mode is set to one, the assets will no
longer be read- or writeable, even if system_mode is set to zero at a
later syscall. This is to make sure syscalls does not have the same
privilege as the firmware has at first boot.

We need to monitor when system_mode is set to one, otherwise we might
accedentially lock the assets before actually leaving firmware, for
example if firmware would use a function set in any of the registers
used in system_mode_ctrl.

Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-12 11:08:27 +01:00
Mikael Ågren
eacfd6eddc
PoC: Remove low privilege syscall 2025-02-12 11:08:27 +01:00
Daniel Jobson
beb325b683
PoC: Deny access to the SPI master in app mode
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-12 11:08:26 +01:00
Mikael Ågren
2e1925555d
PoC: Add example firmware with embedded that calls syscalls implemented in C
App is embedded in firmware and is loaded into app RAM when firmware
starts.
App continuously calls SET_LED syscalls.

Simulation: `make tb_application_fpga_irqpoc_c_example`
2025-02-12 11:08:26 +01:00
Mikael Ågren
e1d7608897
PoC: Control access to FW RAM
Allow FW RAM access only in the following execution contexts:
- Firmware mode
- IRQ_SYSCALL_HI

Input port `system_mode` of the `fw_ram` module is replaced with an
enable port. Since access to FW RAM not longer depend only on
system_mode
2025-02-12 11:08:26 +01:00
Mikael Ågren
0183f25170
PoC: Add basic syscall example firmware
Adds a basic example firmware that copies an app to app RAM. The app
triggers syscall interrupts and tries to execute ROM code from app mode.

A make target (`tb_application_fpga_irqpoc_with_app`) that simulates a
Tkey running the firmware is added.
2025-02-12 11:08:25 +01:00
Mikael Ågren
89c77ca4de
PoC: Trap when executing from ROM in app mode
Only allow executing from ROM when in one of the following execution
contexts:
- Firmware mode
- IRQ_SYSCALL_LO
- IRQ_SYSCALL_HI

Co-authored-by: Daniel Jobson <jobson@tillitis.se>
2025-02-12 11:08:25 +01:00
Mikael Ågren
cd959e9966
PoC: Remove Blake2s register 2025-02-12 11:08:25 +01:00
Daniel Jobson
e18eb03c4f
PoC: Automatically control system_mode in hardware
Instead of manually switching to app mode using the system mode
register, app mode will be enabled when executing outside of firmware
ROM.

Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-12 11:08:24 +01:00
Mikael Ågren
5dfe549969
PoC: Add LED toggling interrupt example
Add example firmware for demoing interrupts on Tkey hardware.
2025-02-12 11:08:24 +01:00
Mikael Ågren
5e15b40a86
PoC: PicoRV32 interrupts
A proof-of-concept of enabling PicoRV32 interrupts. Two interrupt
sources, which can be triggered by writes to memory addresses, are
added.  The design has only been simulated, not run on hardware.

Synthesis:

Ice40 LC utilization is 93% (4934/5280) when built using tkey-builder:4

Simulation:

A `tb_application_fpga_irqpoc` target is added. Running `make
tb_application_fpga_irqpoc` creates `tb_application_fpga_sim.fst` which
can be inspected in GTKWave or Surfer.

Firmware:

A simple firmware is added in `fw/irqpoc`. It enables both interrupts
and triggers each interrupt once.

Custom PicoRV32 instructions are located in `custom_ops.S`. It is
imported from upstream PicoRV32 commit:
70f3c33ac8
2025-02-12 11:08:15 +01:00
Michael Cardell Widerkrantz
d2c7fb0ba9
doc: Update firmware README to include USB Mode Protocol
+ minor link and typo fixes.
2025-02-11 15:21:02 +01:00
Michael Cardell Widerkrantz
179c13e9bf
build: Update digests of firmware and bitstream 2025-02-11 14:40:01 +01:00
Michael Cardell Widerkrantz
050e0f2673
fpga: Format Verilog 2025-02-11 14:37:29 +01:00
Michael Cardell Widerkrantz
aedd6102ea
testfw: Add support for USB Mode Protocol 2025-02-11 14:10:57 +01:00
Michael Cardell Widerkrantz
f68414c4aa
ci: Include Verilog formatting check in CI
- Change checkfmt make target to run both Verilog formatting check and
  C code formatting check.

- Make check formatting it's own job in the CI.
2025-02-11 13:50:08 +01:00
Michael Cardell Widerkrantz
75ad033e03
build: Add -Wno-GENUNNAMED to LINT_FLAGS
For ages we have had a comment saying:

  For Verilator 5.019 -Wno-GENUNNAMED needs to be added to LINT_FLAGS for the
  cell library.

With the new tkey-builder we have 5.028, so it's time to apply this flag.
2025-02-11 13:50:08 +01:00
Michael Cardell Widerkrantz
05bb999759
build/ci: Use new tkey-builder
Use the release candidate for tkey-builder:5
2025-02-11 13:50:07 +01:00
Michael Cardell Widerkrantz
81ac7bffa0
podman/docker: Run bash as login shell
To get bash to source /etc/profile and get the goodness of
/etc/profile/bash_completion.sh, run bash as a login shell.
2025-02-11 13:50:07 +01:00
Michael Cardell Widerkrantz
bb18d5b9e9
toolchain: Introduce buildtools.sh script
Instead of repeated RUNs in Dockerfile, move the entire build of
specific tools to a script.

- Make commands more shell script-like.
- icestorm: Make sure we checkout the right commit.
- Add checks for the right digest for all git clones, so no history
  has been changed.
- Add digest file and check for the downloaded tarball.
tkey-builder-5rc1
2025-02-11 13:50:07 +01:00
Michael Cardell Widerkrantz
8ed16fff6a
docs: Add Castor release notes so far
Breaking change! The introduction of the USB Controller Protocol means
we have a breaking change that makes device apps unable to
communicate.
2025-02-11 13:50:06 +01:00
Jonas Thörnblad
c292595ee3
ch552: Raise UART IRQ priority and tune USB polling period
Set UART1 IRQ to high priority to not miss any incoming bytes
and tune USB polling period (bInterval).
2025-02-11 13:50:06 +01:00
Jonas Thörnblad
361890042a
ch552: Update USB polling period
Update USB polling period (bInterval) for CDC, HID and TKEYCTRL
endpoints.
2025-02-11 13:50:06 +01:00
Jonas Thörnblad
5029eb1d39
ch552: Fix CDC configuration problem on Windows
Fix CDC configuration problem on Windows when we have a composite
device (multiple different Device Classes). Add "Interface Association
Descriptor" to make it work.
2025-02-11 13:50:05 +01:00