pull/273/head
RobertGawron 2025-06-27 08:28:52 +02:00
rodzic 5df277b93a
commit 3520c59edf
6 zmienionych plików z 1750 dodań i 1748 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
# Use an official Ubuntu as a base image
FROM ubuntu:20.04 AS build
FROM ubuntu:25.04 AS build
# Set environment variables to prevent interaction during installation
ENV DEBIAN_FRONTEND=noninteractive
@ -11,84 +11,8 @@ RUN apt-get update && apt-get install -y \
cmake \
pkg-config \
libusb-1.0-0-dev \
&& rm -rf /var/lib/apt/lists/*
# Install stm8flash
RUN git clone https://github.com/vdudouyt/stm8flash.git
RUN cd stm8flash && make -j$(nproc)
# Use another Ubuntu image for runtime
FROM ubuntu:20.04 AS runtime
# Set environment variables to prevent interaction during installation
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libusb-1.0-0 \
sdcc \
build-essential \
cmake \
git \
make \
pkg-config \
libusb-1.0-0-dev \
screen \
doxygen \
uncrustify \
python3-pip \
poppler-utils \
cppcheck \
r-base-core \
shellcheck \
dos2unix \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# Copy the stm8flash binary from the build stage
COPY --from=build /stm8flash/stm8flash /usr/bin/
# Install flake8 in a Python virtual environment
RUN python3 -m venv /workspace/venv && \
/workspace/venv/bin/pip install --upgrade pip && \
/workspace/venv/bin/pip install flake8 flake8-html pyserial CodeChecker coverxygen
# Install R libraries
RUN R -e "install.packages('latticeExtra', repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('gridExtra', repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('Hmisc', repos='http://cran.rstudio.com/')"
# Create workspace directory and set it as the working directory
RUN mkdir -p /workspace/build
WORKDIR /workspace/build
RUN apt-get update && apt-get install -y \
libcunit1-dev \
libcmocka-dev \
tree \
vim \
lcov \
gcovr \
clang
RUN /workspace/venv/bin/pip install --upgrade pip && \
/workspace/venv/bin/pip install \
prospector \
vjunit
RUN apt-get update && apt-get install -y \
uncrustify
RUN apt-get update && apt-get install -y \
clang-tidy
RUN apt-get update && apt-get install -y \
openocd
# Command to run the container
CMD ["bash"]

Wyświetl plik

@ -29,7 +29,11 @@ docker-compose exec ionizationchamber bash
End of Work
To log out from the Docker container, press Ctrl+D.
To stop and clean up the Docker environment, use:
To stop and clean up the Docker
environment, use:
docker-compose down --remove-orphans
@ -274,5 +278,87 @@ stm8flash -c stlinkv2 -p stm8s003f3 -w /workspace/firmwarev3/IonizationChamber.e
------------
openocd -f interface/stlink.cfg -f target/stm8s.cfg -c "program /workspace/firmwarev3/IonizationChamber.elf verify reset exit"
openocd -f interface/stlink.cfg -f target/stm8s.cfg -c "program IonizationChamber.elf verify reset exit"
-------------
SWITCH TO MAKFILE
openocd -f interface/stlink.cfg -f target/stm8s.cfg -c "init; reset halt; load_image IonizationChamber.elf 0x8000; reset halt; exit"
openocd \
-f interface/stlink.cfg \
-f target/stm8s.cfg \
-c "init; reset halt; load_image /workspace/Software/Firmware/IonizationChamber.elf 0x8000; reset halt"
stm8-gdb /workspace/Software/Firmware/IonizationChamber.elf \
-ex "set architecture stm8" \
-ex "target extended-remote :3333"
for sdcc to have elf
sudo apt install build-essential libboost-all-dev bison flex texinfo zlib1g-dev
we dont have elf possibility in this shit
need to update docker for ubuntu version
sudo apt install software-properties-common
root@faedc67c011c:/workspace/Software/Firmware# add-apt-repository ppa:mhier/libboost-latest
it all failed try again:
sudo add-apt-repository ppa:mhier/libboost-latest
sudo apt update
Step 2: Install the desired Boost version (e.g., 1.83)
sudo apt install libboost1.83-dev
and then faild, disable other chips:
./configure --enable-stm8 --disable-hc08 --disable-s08 --disable-mcs51 --disable-z80 --disable-z180 --disable-r2k --disable-r3ka --disable-gbz80 --disable-tlcs90 --disable-ds390 --disable-ds400 --disable-pic14 --disable-pic16 --disable-ucsim
===========================
give up, start new docker
apt install autoconf automake libtool
git clone git@github.com:ntfreak/openocd.git
cd openocd
./bootstrap
./configure
make -j24
make install
what?
git config --global --add safe.directory /workspace/Software/downloads/openocd
./configure --disable-werror
-- shit didint work
apt-get install texinfo
ok make sure the link is ok to the gz file
CPPFLAGS="-D_XOPEN_SOURCE=1"

Wyświetl plik

@ -29,14 +29,13 @@
/* Includes ------------------------------------------------------------------*/
#include "stm8_it.h"
#include "application_builder.h"
#include "user_interface.h"
#include "app_builder.h"
/** @addtogroup Template_Project
* @{
*/
#include "application_builder.h" // Include the flag declaration
extern unsigned char timer_flag;
/* Private typedef -----------------------------------------------------------*/
@ -241,12 +240,13 @@ INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
USER_INTERFACE_COLLECTING_DATA_MSG,
USER_INTERFACE_DISABLE);
*/
/*
user_interface_update_message(
USER_INTERFACE_COLLECTING_DATA_MSG,
USER_INTERFACE_ENABLE);
app_tick_flag = 1;
*/
xx app_builder_tick();
// app_tick_flag = 1;
TIM1_ClearITPendingBit(TIM1_IT_UPDATE);
}

Wyświetl plik

@ -191,10 +191,7 @@
#define __STM8S_STDPERIPH_VERSION_SUB1 ((uint8_t)0x02) /*!< [23:16] sub1 version */
#define __STM8S_STDPERIPH_VERSION_SUB2 ((uint8_t)0x00) /*!< [15:8] sub2 version */
#define __STM8S_STDPERIPH_VERSION_RC ((uint8_t)0x00) /*!< [7:0] release candidate */
#define __STM8S_STDPERIPH_VERSION ( (__STM8S_STDPERIPH_VERSION_MAIN << 24)\
|(__STM8S_STDPERIPH_VERSION_SUB1 << 16)\
|(__STM8S_STDPERIPH_VERSION_SUB2 << 8)\
|(__STM8S_STDPERIPH_VERSION_RC))
#define __STM8S_STDPERIPH_VERSION ((__STM8S_STDPERIPH_VERSION_MAIN << 24) | (__STM8S_STDPERIPH_VERSION_SUB1 << 16) | (__STM8S_STDPERIPH_VERSION_SUB2 << 8) | (__STM8S_STDPERIPH_VERSION_RC))
/******************************************************************************/
@ -239,15 +236,31 @@ typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef enum
{
FALSE = 0,
TRUE = !FALSE
} bool;
typedef enum {FALSE = 0, TRUE = !FALSE} bool;
typedef enum
{
RESET = 0,
SET = !RESET
} FlagStatus,
ITStatus, BitStatus, BitAction;
typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction;
typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
typedef enum
{
DISABLE = 0,
ENABLE = !DISABLE
} FunctionalState;
#define IS_FUNCTIONALSTATE_OK(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
typedef enum
{
ERROR = 0,
SUCCESS = !ERROR
} ErrorStatus;
#define U8_MAX (255)
#define S8_MAX (127)
@ -281,8 +294,7 @@ typedef struct GPIO_struct
__IO uint8_t DDR; /*!< Data Direction Register */
__IO uint8_t CR1; /*!< Configuration Register 1 */
__IO uint8_t CR2; /*!< Configuration Register 2 */
}
GPIO_TypeDef;
} GPIO_TypeDef;
/** @addtogroup GPIO_Registers_Reset_Value
* @{
@ -342,8 +354,7 @@ GPIO_TypeDef;
__IO uint8_t AWSRL; /*!< ADC1 watchdog status register low */
__IO uint8_t AWCRH; /*!< ADC1 watchdog control register high */
__IO uint8_t AWCRL; /*!< ADC1 watchdog control register low */
}
ADC1_TypeDef;
} ADC1_TypeDef;
/** @addtogroup ADC1_Registers_Reset_Value
* @{
@ -405,8 +416,7 @@ GPIO_TypeDef;
__IO uint8_t DRL; /*!< ADC2 Data low */
__IO uint8_t TDRH; /*!< ADC2 Schmitt trigger disable register high */
__IO uint8_t TDRL; /*!< ADC2 Schmitt trigger disable register low */
}
ADC2_TypeDef;
} ADC2_TypeDef;
/** @addtogroup ADC2_Registers_Reset_Value
* @{
@ -450,8 +460,7 @@ typedef struct AWU_struct
__IO uint8_t CSR; /*!< AWU Control status register */
__IO uint8_t APR; /*!< AWU Asynchronous prescaler buffer */
__IO uint8_t TBR; /*!< AWU Time base selection register */
}
AWU_TypeDef;
} AWU_TypeDef;
/** @addtogroup AWU_Registers_Reset_Value
* @{
@ -488,8 +497,7 @@ AWU_TypeDef;
typedef struct BEEP_struct
{
__IO uint8_t CSR; /*!< BEEP Control status register */
}
BEEP_TypeDef;
} BEEP_TypeDef;
/** @addtogroup BEEP_Registers_Reset_Value
* @{
@ -529,8 +537,7 @@ typedef struct CLK_struct
uint8_t RESERVED1; /*!< Reserved byte */
__IO uint8_t HSITRIMR; /*!< HSI Calibration Trimmer Register */
__IO uint8_t SWIMCCR; /*!< SWIM clock control register */
}
CLK_TypeDef;
} CLK_TypeDef;
/** @addtogroup CLK_Registers_Reset_Value
* @{
@ -651,8 +658,7 @@ typedef struct TIM1_struct
__IO uint8_t BKR; /*!< Break Register */
__IO uint8_t DTR; /*!< dead-time register */
__IO uint8_t OISR; /*!< Output idle register */
}
TIM1_TypeDef;
} TIM1_TypeDef;
/** @addtogroup TIM1_Registers_Reset_Value
* @{
@ -856,8 +862,7 @@ typedef struct TIM2_struct
__IO uint8_t CCR2L; /*!< capture/compare register 2 low */
__IO uint8_t CCR3H; /*!< capture/compare register 3 high */
__IO uint8_t CCR3L; /*!< capture/compare register 3 low */
}
TIM2_TypeDef;
} TIM2_TypeDef;
/** @addtogroup TIM2_Registers_Reset_Value
* @{
@ -976,8 +981,7 @@ typedef struct TIM3_struct
__IO uint8_t CCR1L; /*!< capture/compare register 1 low */
__IO uint8_t CCR2H; /*!< capture/compare register 2 high */
__IO uint8_t CCR2L; /*!< capture/compare register 2 low */
}
TIM3_TypeDef;
} TIM3_TypeDef;
/** @addtogroup TIM3_Registers_Reset_Value
* @{
@ -1076,8 +1080,7 @@ typedef struct TIM4_struct
__IO uint8_t CNTR; /*!< counter register */
__IO uint8_t PSCR; /*!< prescaler register */
__IO uint8_t ARR; /*!< auto-reload register */
}
TIM4_TypeDef;
} TIM4_TypeDef;
/** @addtogroup TIM4_Registers_Reset_Value
* @{
@ -1276,8 +1279,7 @@ typedef struct TIM6_struct
__IO uint8_t CNTR; /*!< counter register */
__IO uint8_t PSCR; /*!< prescaler register */
__IO uint8_t ARR; /*!< auto-reload register */
}
TIM6_TypeDef;
} TIM6_TypeDef;
/** @addtogroup TIM6_Registers_Reset_Value
* @{
*/
@ -1350,8 +1352,7 @@ typedef struct I2C_struct
__IO uint8_t CCRH; /*!< I2C clock control register high */
__IO uint8_t TRISER; /*!< I2C maximum rise time register */
uint8_t RESERVED2; /*!< Reserved byte */
}
I2C_TypeDef;
} I2C_TypeDef;
/** @addtogroup I2C_Registers_Reset_Value
* @{
@ -1450,8 +1451,7 @@ typedef struct ITC_struct
__IO uint8_t ISPR6; /*!< Interrupt Software Priority register 6 */
__IO uint8_t ISPR7; /*!< Interrupt Software Priority register 7 */
__IO uint8_t ISPR8; /*!< Interrupt Software Priority register 8 */
}
ITC_TypeDef;
} ITC_TypeDef;
/** @addtogroup ITC_Registers_Reset_Value
* @{
@ -1482,8 +1482,7 @@ typedef struct EXTI_struct
{
__IO uint8_t CR1; /*!< External Interrupt Control Register for PORTA to PORTD */
__IO uint8_t CR2; /*!< External Interrupt Control Register for PORTE and TLI */
}
EXTI_TypeDef;
} EXTI_TypeDef;
/** @addtogroup EXTI_Registers_Reset_Value
* @{
@ -1512,8 +1511,6 @@ EXTI_TypeDef;
* @}
*/
/*----------------------------------------------------------------------------*/
/**
* @brief FLASH program and Data memory (FLASH)
@ -1532,8 +1529,7 @@ typedef struct FLASH_struct
__IO uint8_t PUKR; /*!< Flash program memory unprotection register */
uint8_t RESERVED3; /*!< Reserved byte */
__IO uint8_t DUKR; /*!< Data EEPROM unprotection register */
}
FLASH_TypeDef;
} FLASH_TypeDef;
/** @addtogroup FLASH_Registers_Reset_Value
* @{
@ -1606,8 +1602,7 @@ typedef struct OPT_struct
uint8_t RESERVED2; /*!< Reserved Option byte*/
__IO uint8_t OPT7; /*!< Option byte 7: flash wait states */
__IO uint8_t NOPT7; /*!< Complementary Option byte 7 */
}
OPT_TypeDef;
} OPT_TypeDef;
/*----------------------------------------------------------------------------*/
/**
@ -1619,8 +1614,7 @@ typedef struct IWDG_struct
__IO uint8_t KR; /*!< Key Register */
__IO uint8_t PR; /*!< Prescaler Register */
__IO uint8_t RLR; /*!< Reload Register */
}
IWDG_TypeDef;
} IWDG_TypeDef;
/** @addtogroup IWDG_Registers_Reset_Value
* @{
@ -1642,8 +1636,7 @@ typedef struct WWDG_struct
{
__IO uint8_t CR; /*!< Control Register */
__IO uint8_t WR; /*!< Window Register */
}
WWDG_TypeDef;
} WWDG_TypeDef;
/** @addtogroup WWDG_Registers_Reset_Value
* @{
@ -1679,8 +1672,7 @@ WWDG_TypeDef;
typedef struct RST_struct
{
__IO uint8_t SR; /*!< Reset status register */
}
RST_TypeDef;
} RST_TypeDef;
/** @addtogroup RST_Registers_Bits_Definition
* @{
@ -1711,8 +1703,7 @@ typedef struct SPI_struct
__IO uint8_t CRCPR; /*!< SPI CRC polynomial register */
__IO uint8_t RXCRCR; /*!< SPI Rx CRC register */
__IO uint8_t TXCRCR; /*!< SPI Tx CRC register */
}
SPI_TypeDef;
} SPI_TypeDef;
/** @addtogroup SPI_Registers_Reset_Value
* @{
@ -1785,8 +1776,7 @@ typedef struct UART1_struct
__IO uint8_t CR5; /*!< UART1 control register 5 */
__IO uint8_t GTR; /*!< UART1 guard time register */
__IO uint8_t PSCR; /*!< UART1 prescaler register */
}
UART1_TypeDef;
} UART1_TypeDef;
/** @addtogroup UART1_Registers_Reset_Value
* @{
@ -1884,8 +1874,7 @@ typedef struct UART2_struct
__IO uint8_t CR6; /*!< UART1 control register 6 */
__IO uint8_t GTR; /*!< UART1 guard time register */
__IO uint8_t PSCR; /*!< UART1 prescaler register */
}
UART2_TypeDef;
} UART2_TypeDef;
/** @addtogroup UART2_Registers_Reset_Value
* @{
@ -1971,7 +1960,6 @@ UART2_TypeDef;
* @}
*/
/*----------------------------------------------------------------------------*/
/**
* @brief LIN Universal Asynchronous Receiver Transmitter (UART3)
@ -1989,8 +1977,7 @@ typedef struct UART3_struct
__IO uint8_t CR4; /*!< control register 4 */
uint8_t RESERVED; /*!< Reserved byte */
__IO uint8_t CR6; /*!< control register 5 */
}
UART3_TypeDef;
} UART3_TypeDef;
/** @addtogroup UART3_Registers_Reset_Value
* @{
@ -2083,8 +2070,7 @@ typedef struct UART4_struct
__IO uint8_t CR6; /*!< UART4 control register 6 */
__IO uint8_t GTR; /*!< UART4 guard time register */
__IO uint8_t PSCR; /*!< UART4 prescaler register */
}
UART4_TypeDef;
} UART4_TypeDef;
/** @addtogroup UART4_Registers_Reset_Value
* @{
@ -2386,7 +2372,6 @@ typedef struct
#define CAN_IER_FOVIE ((uint8_t)0x08)
#define CAN_IER_WKUIE ((uint8_t)0x80)
/* CAN diagnostic Register bits */
#define CAN_DGR_LBKM ((uint8_t)0x01)
#define CAN_DGR_SLIM ((uint8_t)0x02)
@ -2394,7 +2379,6 @@ typedef struct
#define CAN_DGR_RX ((uint8_t)0x08)
#define CAN_DGR_TXM2E ((uint8_t)0x10)
/* CAN page select Register bits */
#define CAN_PSR_PS0 ((uint8_t)0x01)
#define CAN_PSR_PS1 ((uint8_t)0x02)
@ -2414,7 +2398,6 @@ typedef struct
#define CAN_MIDR1_RTR ((uint8_t)0x20)
#define CAN_MIDR1_IDE ((uint8_t)0x40)
/************************* Filter Page ****************************************/
/* CAN Error Status Register bits */
@ -2530,8 +2513,7 @@ typedef struct
typedef struct CFG_struct
{
__IO uint8_t GCR; /*!< Global Configuration register */
}
CFG_TypeDef;
} CFG_TypeDef;
/** @addtogroup CFG_Registers_Reset_Value
* @{
@ -2715,7 +2697,6 @@ CFG_TypeDef;
#define DM ((DM_TypeDef *)DM_BaseAddress)
#ifdef USE_STDPERIPH_DRIVER
#include "stm8s_conf.h"
#endif
@ -2734,23 +2715,69 @@ CFG_TypeDef;
#define wfi() _wfi_() /* Wait For Interrupt */
#define halt() _halt_() /* Halt */
#elif defined(_COSMIC_)
#define enableInterrupts() {_asm("rim\n");} /* enable interrupts */
#define disableInterrupts() {_asm("sim\n");} /* disable interrupts */
#define rim() {_asm("rim\n");} /* enable interrupts */
#define sim() {_asm("sim\n");} /* disable interrupts */
#define nop() {_asm("nop\n");} /* No Operation */
#define trap() {_asm("trap\n");} /* Trap (soft IT) */
#define wfi() {_asm("wfi\n");} /* Wait For Interrupt */
#define halt() {_asm("halt\n");} /* Halt */
#define enableInterrupts() \
{ \
_asm("rim\n"); \
} /* enable interrupts */
#define disableInterrupts() \
{ \
_asm("sim\n"); \
} /* disable interrupts */
#define rim() \
{ \
_asm("rim\n"); \
} /* enable interrupts */
#define sim() \
{ \
_asm("sim\n"); \
} /* disable interrupts */
#define nop() \
{ \
_asm("nop\n"); \
} /* No Operation */
#define trap() \
{ \
_asm("trap\n"); \
} /* Trap (soft IT) */
#define wfi() \
{ \
_asm("wfi\n"); \
} /* Wait For Interrupt */
#define halt() \
{ \
_asm("halt\n"); \
} /* Halt */
#elif defined(_SDCC_)
#define enableInterrupts() {__asm__("rim\n");} /* enable interrupts */
#define disableInterrupts() {__asm__("sim\n");} /* disable interrupts */
#define rim() {__asm__("rim\n");} /* enable interrupts */
#define sim() {__asm__("sim\n");} /* disable interrupts */
#define nop() {__asm__("nop\n");} /* No Operation */
#define trap() {__asm__("trap\n");} /* Trap (soft IT) */
#define wfi() {__asm__("wfi\n");} /* Wait For Interrupt */
#define halt() {__asm__("halt\n");} /* Halt */
#define enableInterrupts() \
xxx { __asm__("rim\n"); } /* enable interrupts */
#define disableInterrupts() \
{ \
__asm__("sim\n"); \
} /* disable interrupts */
#define rim() \
{ \
__asm__("rim\n"); \
} /* enable interrupts */
#define sim() \
{ \
__asm__("sim\n"); \
} /* disable interrupts */
#define nop() \
{ \
__asm__("nop\n"); \
} /* No Operation */
#define trap() \
{ \
__asm__("trap\n"); \
} /* Trap (soft IT) */
#define wfi() \
{ \
__asm__("wfi\n"); \
} /* Wait For Interrupt */
#define halt() \
{ \
__asm__("halt\n"); \
} /* Halt */
#else /*_IAR_*/
#include <intrinsics.h>
#define enableInterrupts() __enable_interrupt() /* enable interrupts */
@ -2763,7 +2790,6 @@ CFG_TypeDef;
#define halt() __halt() /* Halt */
#endif /*_RAISONANCE_*/
/*============================== Interrupt vector Handling ========================*/
#ifdef _COSMIC_
@ -2817,9 +2843,7 @@ Comments : The different parameters of commands are
#define ClrBit(VAR, Place) ((VAR) &= (uint8_t)((uint8_t)((uint8_t)1 << (uint8_t)(Place)) ^ (uint8_t)255))
#define ChgBit(VAR, Place) ((VAR) ^= (uint8_t)((uint8_t)1 << (uint8_t)(Place)))
#define AffBit(VAR,Place,Value) ((Value) ? \
((VAR) |= ((uint8_t)1<<(Place))) : \
((VAR) &= (((uint8_t)1<<(Place))^(uint8_t)255)))
#define AffBit(VAR, Place, Value) ((Value) ? ((VAR) |= ((uint8_t)1 << (Place))) : ((VAR) &= (((uint8_t)1 << (Place)) ^ (uint8_t)255)))
#define MskBit(Dest, Msk, Src) ((Dest) = ((Msk) & (Src)) | ((~(Msk)) & (Dest)))
#define ValBit(VAR, Place) ((uint8_t)(VAR) & (uint8_t)((uint8_t)1 << (uint8_t)(Place)))

Wyświetl plik

@ -1,22 +0,0 @@
# STM8 Debug Configuration for OpenOCD 0.10.0
interface stlink
transport select swim
# STM8S003 Settings
set CHIPNAME stm8s003
# Target setup
swim newtap $CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf
target create $CHIPNAME.cpu stm8 -endian little -chain-position $CHIPNAME.cpu
# Flash configuration (8KB)
flash bank $_FLASHNAME stm8 0x8000 0 0 0 $CHIPNAME.cpu
# Reset configuration
reset_config srst_only
# Speed settings
stlink_set_swd_freq 100
# Initialize
init

Wyświetl plik

@ -1,10 +0,0 @@
# stm8s003.cfg
source [find target/swim.cfg]
transport select swim
# Chip parameters (adjust as needed)
set CHIPNAME stm8s003
set WORKAREASIZE 0x400 # RAM size
# Flash configuration
flash bank $_FLASHNAME stm8 0x8000 0 0 0 $_TARGETNAME