Commit Graph

1658 Commits

Author SHA1 Message Date
Stefan Kerkmann b5d78c64c4 Add RV32E support
* Make SP 16 byte aligned as the risc-v abi wants it.
* Correct IRQ context check.
2021-05-10 10:16:54 +02:00
Stefan Kerkmann 5e096e01c9 Context switch only on irq tail 2021-05-09 11:16:09 +02:00
Michael Stapelberg dcf1cdd589 Teensy 4.1 demo: start USB serial shell after control line state
Without this change, the ChibiOS shell prompt does not show up reliably on
Linux, and possibly other operating systems.

For a detailed walk-through covering the individual problems and causes, see:
https://michael.stapelberg.ch/posts/2021-04-27-linux-usb-virtual-serial-cdc-acm/

I verified that this approach works with:

1. Linux 5.10
2. Windows 10
3. macOS Big Sur on a MacBook Air M1
2021-04-27 08:31:54 +02:00
Fabien Poussin 9c2bfa6aeb
Merge pull request #277 from KarlK90/risc-v-eclic-t0-restore-fix
[RISC-V ECLIC] Fix t0 restore when exiting interrupt
2021-04-26 16:59:35 +02:00
Stefan Kerkmann 0a66a0660b Fix t0 restore when exiting interrupt
An oversight when arrangeing the code according to the nucleisys docs,
t0 was overriden with the value of msubm and never actually restored. To
fix the issue we restore the csrs after the general purpose registers.
The offical docs want it the other way around but this should be fine as
well, as the interrupts are still globaly disabled at this point.
2021-04-25 13:23:47 +02:00
Fabien Poussin d53c82a884
Merge pull request #276 from KarlK90/gd32vf103-add-crc
[GD32VF103] Add CRC driver
2021-04-21 22:28:35 +02:00
Stefan Kerkmann e64aa96319 Fix Longan Nano Red LED define 2021-04-20 22:04:07 +02:00
Stefan Kerkmann 0daa76501f Add crc driver for gd32vf103 2021-04-20 15:09:07 +02:00
Fabien Poussin 13d28c1e13
Merge pull request #275 from KarlK90/risc-v-eclic-illegal-instruction-fix
[RISC-V ECLIC] Illegal instruction exception on MSTATUS access
2021-04-17 21:13:10 +02:00
Stefan Kerkmann 9a64f5c17c Force machine mode on interrupt exit for context switches
The first attempt to solve illegal instruction expections was made in commit
b875108cd0
 It seemed as this "fixed" the issue, but merely added delays in the code
 which prevented the error to appear in lucky circumstances. Interesting that this code worked in the first place.

Root cause for the expections where write attempts to mstatus in
user privilege mode which raised the illegal instruction exception which
is in spec with the risc-v privileged isa and documented in the
bumbleebee core architecture manual by nucleisys. The solution is
to never enter user mode by forceing mcause.mpp to 0x3
before calling mret when exiting the interrupt handler
for context switching.
2021-04-17 19:36:44 +02:00
Stefan Kerkmann c1dfb65aa0 Revert "Add R/W memory and instruction barrier after mstatus access"
This reverts commit b875108cd0.
2021-04-16 21:52:41 +02:00
Fabien Poussin 9dbe061083
Merge pull request #273 from KarlK90/gd32vf103-i2c-fix
[GD32] Fix I2C Hangups
2021-04-16 17:23:13 +02:00
Fabien Poussin e9657f6468
Merge branch 'chibios-20.3.x' into gd32vf103-i2c-fix 2021-04-16 16:32:30 +02:00
Fabien Poussin f8bb6d9332
Merge pull request #274 from KarlK90/risc-v-eclic-fence-fix
[RISC-V ECLIC] Add R/W memory and instruction barrier after mstatus access
2021-04-16 16:31:18 +02:00
Stefan Kerkmann b875108cd0 Add R/W memory and instruction barrier after mstatus access
Fast subsequent reads and writes to the mstatus csr lead to
illegal instruction exceptions on the nucleisys bumblee core
of the gd32vf103. This behavior only occurred in high load
situations e.g. interrupt frequency of 5khz but reliably let
to these errors.  Adding the instruction and memory barriers solved
the problem. There is some negligible performance impact.
2021-04-16 16:10:08 +02:00
Stefan Kerkmann 863082ac44 Remove unnecessary if clause 2021-04-15 14:49:43 +02:00
Stefan Kerkmann 764203444a Move DMA enable to init code, re-add spurious bus error clearance 2021-04-14 22:16:40 +02:00
a_p_u_r_o fe3cdf8314
Merge pull request #270 from elfmimi/nuc123-efl-fix
Follow-up fix to alexclewontin's nuc123-kvs-example
2021-04-08 20:35:08 +09:00
a_p_u_r_o 6747713b04
Merge branch 'chibios-20.3.x' into nuc123-efl-fix 2021-04-08 20:17:24 +09:00
Fabien Poussin b387cc84d7
Merge pull request #272 from stapelberg/usbendpoints
Fix MIMXRT1062/LLD/USBHSv1: increase USB_DEVICE_CONFIG_ENDPOINTS from 4 to 7 (== USB_MAX_ENDPOINTS)
2021-04-06 22:34:06 +02:00
Fabien Poussin 92eaded978
Merge branch 'chibios-20.3.x' into usbendpoints 2021-04-06 22:09:08 +02:00
Fabien Poussin 13f99fdf34
Merge pull request #266 from KarlK90/gd32vf103-riscv-eclic
[RISC-V] ECLIC Port and GD32VF103 HAL Support
2021-04-06 22:08:20 +02:00
Stefan Kerkmann 31f37e99b0 Fix VBUSSENS for Longan Nano 2021-04-06 14:23:27 +02:00
Stefan Kerkmann 35a04fc72c Add myself to copyright notes :-) 2021-04-06 13:38:23 +02:00
Stefan Kerkmann d783126f55 Remove duplicate defines 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 4f56e326a8 Update demo mcuconf.h with ECLIC triggers 2021-04-06 13:38:23 +02:00
Stefan Kerkmann b32f8bbeac Move ECLIC IRQ triggers to driver files 2021-04-06 13:38:23 +02:00
Stefan Kerkmann bd7f5f42a5 Add USB CDC demo for the longan nano board 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 5557082177 Update longan nano board 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 6e2b7317b0 Fix periodic tick timer 2021-04-06 13:38:23 +02:00
Stefan Kerkmann e90664f460 Add Sipeed Longan Nano Board 2021-04-06 13:38:23 +02:00
Stefan Kerkmann fcb66ed300 Add previously undefined constants 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 2463c10bd6 Explicitly define all capabilities in gd32registry 2021-04-06 13:38:23 +02:00
Stefan Kerkmann f39fb50760 Correct default values and usb prescaler defines 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 5dc6aa1d41 Add SystemCoreClock again 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 3c39240a6c Rename STM32 to GD32 2021-04-06 13:38:23 +02:00
Stefan Kerkmann f093fe58b5 Remove STM32 registry 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 93c9c69644 Merge HAL files 2021-04-06 13:38:23 +02:00
Stefan Kerkmann cf2e6d4cea Rename CMSIS header file to gd32vf103.h 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 4206c0469d Remove unused RCU_CFG1 defines 2021-04-06 13:38:23 +02:00
Stefan Kerkmann e6822d95ed Rename RCU registers 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 9ef3cfcc3d Rename RCU_AHBENR 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 7262f2ed74 Rename RCU APB1RSTR register and remove unused peripherals 2021-04-06 13:38:23 +02:00
Stefan Kerkmann f6d7eda01b Renumber SPI RCU defines to begin at 0 2021-04-06 13:38:23 +02:00
Stefan Kerkmann d304133046 Rename RCU_CIR and RCU_APB2RST registers 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 302e61bdcf Remove unused USB OTG Defines 2021-04-06 13:38:23 +02:00
Stefan Kerkmann d25731f7cf Delete unused exti and control defines 2021-04-06 13:38:23 +02:00
Stefan Kerkmann 387ccb8dea Renumber ADC peripherals to begin at 0 2021-04-06 13:38:22 +02:00
Stefan Kerkmann 2cd74f3ea2 Replace GD32_DAC_DAC with GD32_DAC 2021-04-06 13:38:22 +02:00
Stefan Kerkmann c7e847a17a Rename DAC1 to just DAC 2021-04-06 13:38:22 +02:00