Commit Graph

95 Commits

Author SHA1 Message Date
Adeeb Shihadeh 272b81e97b
fan: fix stall detection (#1351)
* cleanup and fix

* dos must stall

* clean those up

* fix misra

* more test

* fix import

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-20 15:44:12 -07:00
Adeeb Shihadeh e6cad01955
H7: fix CAN FD IRQ rate (#1332) 2023-04-19 17:34:31 -07:00
Igor Biletskyy 0832d65347
Fix CAN message corruption on H7 under high load (#1342)
* fix RX FIFO corruption

* Add checksum to CANFD test data

* cleaner and MISRA

* nah

* oops

* fix test
2023-04-12 11:07:58 -07:00
Robbe Derks 79708f912d
USB enumeration based on frame numbers (#1324)
* use frame numbers to detect host connection

* fix weird formatting

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-04-03 17:13:02 +02:00
Robbe Derks c0aea3273a
Tres: fan cooldown + no stall recovery (#1287)
* add fan cooldown

* refactor to be inside the fan driver

* fix rebase

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-16 14:15:43 +01:00
Igor Biletskyy 75792fb255
Fix different ADC scales (#1288)
* different ADC scales

* add HITL

* we had it, remove
2023-03-14 14:49:39 -07:00
Adeeb Shihadeh 2de7140117
SPI support in bootstub (#1227)
* always build spi

* no dos for now

* spi gpio init

* detect bootstub

* cleanup

* revert that

* move fx stuff

* fix linter

* set erase timeout

* fix types

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-03-07 14:55:15 -08:00
Robbe Derks 1923b14189
RTC: increase LSE drive strength on H7 (#1252)
* higher LSE drive strength

* split out init per chip type

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-02-24 16:59:58 +01:00
Robbe Derks d6af117c62
Microsecond timer fix (#1236)
* add microsecond timer readout

* add CI test

* fix
2023-02-14 12:16:15 +01:00
Robbe Derks 687676be40
Add timeout to spi driver (#1223)
add timeout to spi driver

Co-authored-by: Comma Device <device@comma.ai>
2023-01-24 13:50:51 +01:00
Robbe Derks 6ba9afc33e
H7 clock source (#1194)
it's literally the same everything

Co-authored-by: Comma Device <device@comma.ai>
2022-12-14 16:12:09 +01:00
Robbe Derks d1d1f8a22d
Fake siren (#1192)
* DAC POC

* change freq

* some cleanup

* wip: cleaning up and trying to use DMA

* no clue why this doesn't work

* this works

* wip multi-master i2c for fake siren

* cleanup and some more i2c stuff

* seems more stable

* retry disabling and cleanup force siren

* fix misra violations

* not needed

* messed up rebase

Co-authored-by: Comma Device <device@comma.ai>
2022-12-14 11:25:54 +01:00
Adeeb Shihadeh e6f62a62aa
rename puts to avoid conflict with stdio.h (#1174)
* rename puts to avoid conflict with stdio.h

* better name
2022-11-29 22:55:10 -08:00
Adeeb Shihadeh ae66bbcaa8
tres fan (#1162)
* fan on

* little cleanup

* move to main
2022-11-17 21:02:37 -08:00
Robbe Derks 5aa5f855e4
setup UART for SOM debugging (#1151)
* cleanup external debug serial

* wip: bring up uart7

* more wip

* this does something

* this works

* increase fifo size

* fix misra

* cleanup

* fix misra again

* add SOM debug enum

* reduce SOM buffer on F4

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-11-17 17:59:11 +01:00
Adeeb Shihadeh e7131fcee0
H7 SPI comms (#1158)
* getting health packets

* start cleanup

* pull state machine out

* cleanup
2022-11-14 13:52:52 -08:00
Robbe Derks 9db0ae7056
Remove external debug UART support (#1159)
cleanup external debug serial
2022-11-14 11:46:04 +01:00
Adeeb Shihadeh c75c276301
add has_spi board property (#1153)
* always spi for h7

* disable for now
2022-11-13 19:57:20 -08:00
Igor Biletskyy cc3b7d9470
H7: add comments on buses clocks (#1154)
comment
2022-11-11 15:30:37 -08:00
Igor Biletskyy a9e0357883
H7: enable USB LDO and fix RGB LED gpios (#1148)
* enable USB LDO

* open drain for RGB LED gpios

* naming

* comment
2022-11-10 19:29:44 -08:00
Robbe Derks d574f4aebc
STM32F4: SPI communications (#998)
* cleanup is_enumerated, rename comms and init spi

* big comms refactor, building now

* misra fixes

* more fixes

* misra try 3

* cleanup

* this belongs in a separate PR

* remove unneccesary file

* revert llspi changes

* llspi misra fix

* enable SPI on F4 and setup gpio

* duh

* wip: spi comms

* more spi wip

* dynamic sector erasing

* Revert "dynamic sector erasing"

This reverts commit fce1215a2e.

* more sectors to be erased

* debugging

* woah, this works

* cleanup on the panda side

* add sync and checksum checks, and fix recovery on errors

* this seems relatively stable

* add retrying

* this is stabler

* some endianness and endpoint fixes

* builds

* revert that

* add that back

* checksum start

* start splitting up driver

* spi behind flag

* cleanup test

* bump up timeout

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2022-11-09 18:46:20 -08:00
Adeeb Shihadeh 49e2034098
tres (#1130)
* tres

* pull out chiplet

* add to python lib
2022-11-03 16:34:18 -07:00
Igor Biletskyy f7c74e08c6
bugfix: D2 SRAM clocks and CRun CPU state (#1125)
D2 SRAM clocks
2022-11-02 14:28:23 -07:00
Igor Biletskyy bd8d2481dd
H7: free up 29120 bytes of RAM (#1120)
free up some RAM
2022-10-25 21:15:46 -07:00
Greg Hogan 2f3e2825e5
CAN-FD non-ISO support (#1082)
CAN FD non-ISO support
2022-10-12 15:28:20 -07:00
Igor Biletskyy a19f12559e
check if set CAN speed is valid (#1073)
* check

* MISRA
2022-09-16 23:51:55 -07:00
Igor Biletskyy 0eef8cf333
CAN: health message for each CAN module (#1067)
* initial can health pkt

* MISRA: variable scope

* MISRA 10.4

* typo

* add total_fwd_cnt

* check size of can_health_t

* improve

* comment

* that's better

* move

* add health check to tests

* why?

* ...

* revert later

* meh

* Revert "meh"

This reverts commit 0eb8432194.

* Revert "revert later"

This reverts commit 2d98957a8f.

* adjust test
2022-09-15 13:04:10 -07:00
Igor Biletskyy 15eda6a7c9
CAN bus: adjust SJW and time quanta to SAE 2284-3 (#1061)
* adjust clocks and tq

* debug console keyboard interrupt

* MISRA
2022-09-12 14:31:22 -07:00
Igor Biletskyy ac21dbe551
H7: add chiplet panda support (RPv2) (#1049)
* temporarily disable Jenkins

* firmware

* python lib

* tests

* ..

* usb load switch to high

* it is still red

* usb power mode remove

* Revert "temporarily disable Jenkins"

This reverts commit a911cfad8d.

* forgot this

* common periph

* change name

* board tick

* add V2 to CI

* update known bootstub
2022-09-09 20:13:06 -07:00
Robbe Derks d24971ef8a
Communication refactor (#997)
* cleanup is_enumerated, rename comms and init spi

* big comms refactor, building now

* misra fixes

* more fixes

* misra try 3

* cleanup

* this belongs in a separate PR

* remove unneccesary file

* revert llspi changes

* this needs packing

* fix pedal usb

Co-authored-by: Comma Device <device@comma.ai>
2022-08-03 13:11:52 +02:00
Robbe Derks cc0fdffee6
Calculate interrupt load and add to health packet (#913)
* calculate interrupt load

* forgot to change this

* being cautious about overflows

* utils

* fix bootstub

* cleanup

* also exclude pedal

* fix misra

Co-authored-by: Comma Device <device@comma.ai>
2022-04-11 11:59:47 +02:00
Igor Biletskyy de7e1e7579
Deep sleep(stop) mode for pandas (#832)
* Add RTC with LSI for BP, GP, WP

* disable jenkins temporarily, REVERT!

* experiments

* cleanup is still needed

* cppcheck unused suppress

* raise deepsleep limit timeout to 120sec

* more experiments on usb_enumerated

* continue

* soft_disconnect

* almost done

* not enough

* no ignition

* still don't like it..

* rename to has_rtc_battery

* clock_source on the way!?

* delay 3 sec

* works on C3, needs test on C2

* And this is for C2

* disable bootkick

* misra 10.4

* ..

* ..

* set power state the right way

* change that

* seems don't need that? check on C2/C3

* partially works on RP...

* comments (will work after rebase)

* change fault name

* switch to manual activation mode

* Revert "disable jenkins temporarily, REVERT!"

This reverts commit 578d425fa7.

* my dear pedal!
2022-03-07 14:24:04 -08:00
Igor Biletskyy 8435bda1d2
CAN FD: adjust bit timing settings to SAE specifications J2284-4 and J2284-5 (#861)
* try that

* revert to SAE and remove TDC

* add support for speed < 250kbps
2022-02-24 14:09:13 -08:00
Igor Biletskyy f56ebf5b77
Revert "Split linker files for STMs F2 and F4 (#817)" (#852)
This reverts commit 5eddc180d5.
2022-02-10 19:25:25 -08:00
Igor Biletskyy ffcba442c3
bug (#850) 2022-02-09 22:01:50 -08:00
Igor Biletskyy 14d7310784
Enable RTC for all pandas (#849)
* rename has_rtc and add rtc_init for panda boards

* change rtc_init
2022-02-09 15:36:37 -08:00
Igor Biletskyy 5eddc180d5
Split linker files for STMs F2 and F4 (#817)
* fix linkers
2022-02-07 16:21:18 -08:00
Igor Biletskyy 8d0d148681
Move shared definitions into separate file (#808)
* refactor definitions includes

* fix include

* revert dlc_to_len

* ...

* change name
2021-12-16 14:38:22 -08:00
Igor Biletskyy 89438c849b
H7: Move from PLL3Q to HSI48 for USB FS (#800) 2021-12-01 20:28:31 -08:00
Igor Biletskyy 571512a392
Change H7 CAN FD clocks to support both 2 and 5 Mbit/s (#781) 2021-11-15 16:28:05 -08:00
Igor Biletskyy ae26b75d7b
CAN_FIFOMailBox to CANPacket struct + USB dynamic packet size (#739)
* Squashed commits, no cleanup

* Few fixes

* No init = garbage

* Only receive with new canpacket

* Add send with canpacket

* Revert "Add send with canpacket"

This reverts commit 7d06686ddd6d447c714b5289d31af24403d36931.

* Packet must be aligned to word, or bad performance

* Cleaner

* Fix tests

* Tests...

* MISRA 10.4

* More MISRA

* libpandasafety_py

* cffi

* even more tests...

* typo

* ...

* ...

* ...

* Slight cleanup

* MISRA 6.1

* MISRA 17.7

* Bug in bxcan + even style

* MISRA 10.1

* Revert "MISRA 10.1"

This reverts commit 404ae7fcc39556f80f528de9015702e69f4ea0a5.

* ...

* MISRA 10.1 and 10.4 suppress until next PR

* MISRA 20.1

* ...

* test_honda

* ...

* ...

* test_toyota

* test_volkswagen_mqb

* test_volkswagen_pq

* Sketchy thing...

* Revert "Sketchy thing..."

This reverts commit 3b2e5715bdc1954f7b7b3b7469ba3d0eaa06bdf9.

* remove comment

* bxcan extended address bug

* Concept, experimental dynamic usb packet size

* increase each buffer to 10240 bytes

* raise python bulk read/write limits

* ...

* Move packet size to start

* Experimental send, stream-like

* New receive test, stream-like

* cleanup

* cleanup + rebase fixes

* MISRA

* Extra receive method, stream-like, commented out

* type change

* Revert back to buffer for send, stream commented

* forgot ZLP

* lower buffer, add rx failsafe

* ... remove ZLP

* return ZLP back

* Add tx checks to panda fw

* TX stream with counter

* fix counter overflow

* 13 free slots should be enough

* limit tx usb packet

* ...

* Revert max_bulk_msg doubling

* python lib improve speed

* Stream with counter for RX, dirty, needs cleanup

* Increase chunk length to 4096 bytes

* cleanup fdcan.h

* cleanup __init__.py

* MISRA 12.1

* MISRA 10.8

* remove non-streaming usb functions

* more main.c cleanup

* MISRA 15.6

* MISRA 15.5

* MISRA 18.4 and suppress objectIndex

* handling usb pakcets > 63bytes, naming and cleanup

* Cleanup old from tests and update CANPacket_t struct

* Switch to 4 bit DLC instead of 6 bit length

* ops)

* ...

* pylint

* receive python buffer increase

* USB increase receive packet len

* tweak buffers

* No need for so high limits

* MISRA 20.1 workaround

* performance tweaks

* cleanup, dlc to data_len_code naming

* main.c naming

* comments and cleanup for main.c usb

* clean py lib

* pylint

* do not discard good rx messages on stream fail

* cleanups

* naming

* remove bitstruct lib and lower tx limit

* bitstruct lefovers

* fix bug in VW test

* remove adjusting data size and assert on wrong len

* ...

* test new memcpy before merging

* Revert "test new memcpy before merging"

This reverts commit 399465a264835061adabdd785718c4b6fc18c267.

* macros for to/fromuint8_t array

* MISRA hates me!

* tests.c include macros instead

* move CANPacket to can_definitions.h

* vw_pq python test fix

* new memcpy test, REMOVE

* check without alignment

* revert macros for uint8 arrays

* Revert "revert macros for uint8 arrays"

This reverts commit 581a9db735a42d0d68200bd270d87a8fd34e43fe.

* check assert

* Revert "check assert"

This reverts commit 9e970d029a50597a1718b2bb0260196c050fd77f.

* one more variation

* Revert "one more variation"

This reverts commit f6c0528b7ac7e125750dc0d9445c7ce97f6954b5.

* what about read performance

* Revert "what about read performance"

This reverts commit d2610f90958a816fe7f1822157a84f85e97d9249.

* check struct alignment to word

* check for aligned memcpy again

* cleanup

* add CANPacket structure diagram

* update CANPacket and add USB packet struct

* bugfix + refactoring of EP1

* move dlc_to_len to header

* missed include

* typo...

* MISRA

* fk

* lower MAX_CAN_MSGS_PER_BULK_TRANSFER

* bump CAN_PACKET_VERSION to 2

* bump python lib CAN_PACKET_VERSION to 2

* rename parse_can_buffer to unpack_can_buffer

* CANPacket_t const fields

* Revert "CANPacket_t const fields"

This reverts commit cf91c035b7706a14e317550c5f0501ae3fce7c70.

* test.c relative path

* cleanup

* move macros to safety_declarations

* Refactor pack/unpack funcs and add unittest

* usb_protocol.h

* oops

* Update .github/workflows/test.yaml

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* remove print from unittest

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-11-12 16:36:34 -08:00
Igor Biletskyy a292d8f09d
Increase data element size for STM32H7 CAN FD TX/RX buffers (#735)
* Change CAN element data size and quantity

* check this way

* ...

* Get ready for CAN FD

* fix MISRA
2021-10-07 11:19:25 -07:00
Igor Biletskyy 87f81b96a5
Move CAN buffers rx_q and txgmlan_q to RAM D1 on STM32H7 (#734)
* Add RAM D1 to linker script

* Check idea with bigger buffers

* Move rx_q and txgmlan to RAM D1 on H7
2021-10-07 11:07:19 -07:00
Igor Biletskyy ad90646001
Support for STM32H7 and Red Panda (#694)
* H7 drivers

* Include H7 into the code

* fix flash write for H7

* get serial from flasher.h from F4 and H7

* flash.sh and recover.sh for gen3

* add set_data_speed for BRS CAN FD

* build all fws

* gen3 to panda lib

* gen3 name in scons project

* disable fd can and brs

* gen3 to CI tests

* jenkins fix for new tests and build_all

* fix pedal test

* pedal in panda tests again...

* cleanup llfdcan.h

* cleanup clock.h

* Add LDORDY bit check instead of delay

* missing define in stm32h735xx.h lib

* board_id helper

* enable debug detection again

* clean gpio inits

* fix board_id helper, make cleaner

* comment MCUs in stm lib for faster misra

* target MCU

* misra-5.5

* improve headers and misra speed

* cleanup CI tests

* change naming from gen3 to h7

* readable if statement

* cleanup llusb.h

* only cycle one transceifer in bus-off

* move unused funcs to common header

* bus_off_err reset

* misra 10.4 fdcan

* extern to can_data_speed variable

* limit can_data_speed array size to 3

* reinit fd can on data speed change

* Improve test with ELM327 and extaddr check

* bugfix for fdcan

* panda python config naming

* abstracted init request in llfdcan

* misra fdcan

* Improve llusb.h for H7
2021-08-02 20:26:15 -07:00
Igor Biletskyy 74eebb828c
Resources for H7 from STM (#696) 2021-07-18 12:51:09 -07:00