Skip to content

Commit

Permalink
Remove flash logging (commaai#1674)
Browse files Browse the repository at this point in the history
* Revert "Disable flash logging (commaai#1667)"

This reverts commit 62db605.

* Revert "Faster log retrieval (commaai#1484)"

This reverts commit 694aae9.

* Revert "Flash bounds checking outside of bootstub (commaai#1459)"

This reverts commit 054344d.

* Revert "Logging (commaai#1445)"

This reverts commit 0cc91a7.

* cleanup

* cleanup
  • Loading branch information
adeebshihadeh authored Sep 30, 2023
1 parent 6d0ffd9 commit b6e37f2
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 619 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ jobs:
run: $RUN "scons -j4"
- name: Test communication protocols
run: $RUN "cd tests/usbprotocol && ./test.sh"
- name: Test logging
run: $RUN "cd tests/logging && ./test.sh"

safety:
name: safety
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .python.serial import PandaSerial # noqa: F401
from .python.canhandle import CanHandle # noqa: F401
from .python import (Panda, PandaDFU, # noqa: F401
pack_can_buffer, unpack_can_buffer, calculate_checksum, unpack_log,
pack_can_buffer, unpack_can_buffer, calculate_checksum,
DLC_TO_LEN, LEN_TO_DLC, ALTERNATIVE_EXPERIENCE, CANPACKET_HEAD_SIZE)


Expand Down
208 changes: 0 additions & 208 deletions board/drivers/logging.h

This file was deleted.

9 changes: 0 additions & 9 deletions board/drivers/logging_definitions.h

This file was deleted.

21 changes: 18 additions & 3 deletions board/drivers/rtc.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

#include "rtc_definitions.h"

#define YEAR_OFFSET 2000U

typedef struct __attribute__((packed)) timestamp_t {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t weekday;
uint8_t hour;
uint8_t minute;
uint8_t second;
} timestamp_t;

uint8_t to_bcd(uint16_t value){
return (((value / 10U) & 0x0FU) << 4U) | ((value % 10U) & 0x0FU);
}
Expand Down Expand Up @@ -43,6 +50,14 @@ void rtc_set_time(timestamp_t time){

timestamp_t rtc_get_time(void){
timestamp_t result;
// Init with zero values in case there is no RTC running
result.year = 0U;
result.month = 0U;
result.day = 0U;
result.weekday = 0U;
result.hour = 0U;
result.minute = 0U;
result.second = 0U;

// Wait until the register sync flag is set
while((RTC->ISR & RTC_ISR_RSF) == 0){}
Expand Down
9 changes: 0 additions & 9 deletions board/drivers/rtc_definitions.h

This file was deleted.

63 changes: 0 additions & 63 deletions board/fake_stm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

#include "utils.h"
#include "drivers/rtc_definitions.h"

#define CANFD
#define ALLOW_DEBUG
Expand Down Expand Up @@ -33,64 +31,3 @@ uint32_t microsecond_timer_get(void);
uint32_t microsecond_timer_get(void) {
return MICROSECOND_TIMER->CNT;
}

// Register functions
void register_set_bits(volatile uint32_t *addr, uint32_t val) {}

// RTC
timestamp_t rtc_get_time() {
timestamp_t result;
result.year = 1996;
result.month = 4;
result.day = 23;
result.weekday = 2;
result.hour = 4;
result.minute = 20;
result.second = 20;
return result;
}

// Logging and flash
uint8_t fake_logging_bank[0x40000] __attribute__ ((aligned (4)));
#define LOGGING_FLASH_BASE_A (&fake_logging_bank[0])
#define LOGGING_FLASH_BASE_B (&fake_logging_bank[0x20000])
#define LOGGING_FLASH_SECTOR_A 5
#define LOGGING_FLASH_SECTOR_B 6
#define LOGGING_FLASH_SECTOR_SIZE 0x20000U

bool flash_locked = true;
void flash_unlock(void) {
flash_locked = false;
}
void flash_lock(void) {
flash_locked = true;
}

void *memset(void *str, int c, unsigned int n);

bool flash_erase_sector(uint8_t sector) {
if (flash_locked) {
return false;
}

switch (sector) {
case LOGGING_FLASH_SECTOR_A:
memset(LOGGING_FLASH_BASE_A, 0xFF, sizeof(fake_logging_bank)/2);
return true;
case LOGGING_FLASH_SECTOR_B:
memset(LOGGING_FLASH_BASE_B, 0xFF, sizeof(fake_logging_bank)/2);
return true;
default:
return false;
}
}

void flash_write_word(void *prog_ptr, uint32_t data) {
if (flash_locked || prog_ptr < (void *) LOGGING_FLASH_BASE_A || prog_ptr >= (void *) (LOGGING_FLASH_BASE_A + sizeof(fake_logging_bank))) {
return;
}

*(uint32_t *)prog_ptr = data;
}

void flush_write_buffer(void) {}
1 change: 0 additions & 1 deletion board/faults.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#define FAULT_INTERRUPT_RATE_UART_7 (1U << 24)
#define FAULT_SIREN_MALFUNCTION (1U << 25)
#define FAULT_HEARTBEAT_LOOP_WATCHDOG (1U << 26)
#define FAULT_LOGGING_RATE_LIMIT (1U << 27)

// Permanent faults
#define PERMANENT_FAULTS 0U
Expand Down
4 changes: 3 additions & 1 deletion board/flasher.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// flasher state variables
uint32_t *prog_ptr = NULL;
bool unlocked = false;

void spi_init(void);

Expand Down Expand Up @@ -32,12 +33,13 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
resp[1] = 0xff;
}
current_board->set_led(LED_GREEN, 1);
unlocked = true;
prog_ptr = (uint32_t *)APP_START_ADDRESS;
break;
// **** 0xb2: erase sector
case 0xb2:
sec = req->param1;
if (flash_erase_sector(sec)) {
if (flash_erase_sector(sec, unlocked)) {
resp[1] = 0xff;
}
break;
Expand Down
Loading

0 comments on commit b6e37f2

Please sign in to comment.