Skip to content

Commit 7d151e8

Browse files
authored
Merge pull request #70 from uhi22/copilot/add-release-qcaflash-build-config
Add ReleaseQCAFlash build with integrated QCA7k flash programming
2 parents 158048e + 583ba33 commit 7d151e8

11 files changed

Lines changed: 1007 additions & 3 deletions

File tree

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ BINARY = stm32_ccs
2323
SIZE = $(PREFIX)-size
2424
CC = $(PREFIX)-gcc
2525
CPP = $(PREFIX)-g++
26+
AS = $(PREFIX)-g++
2627
LD = $(PREFIX)-gcc
2728
OBJCOPY = $(PREFIX)-objcopy
2829
OBJDUMP = $(PREFIX)-objdump
@@ -33,6 +34,7 @@ CFLAGS = -Os -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include -Iexi -Iccs \
3334
CPPFLAGS = -Os -ggdb -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include -Iexi -Iccs \
3435
-fno-common -std=c++11 -pedantic -DSTM32F1 -DUSART_BAUDRATE=921600 \
3536
-ffunction-sections -fdata-sections -fno-builtin -fno-rtti -fno-exceptions -fno-unwind-tables -mcpu=cortex-m3 -mthumb
37+
ASFLAGS = $(CPPFLAGS) -x assembler-with-cpp
3638
# Check if the variable GITHUB_RUN_NUMBER exists. When running on the github actions running, this
3739
# variable is automatically available.
3840
# Create a compiler define with the content of the variable. Or, if it does not exist, use replacement value 0.
@@ -56,11 +58,19 @@ OBJSL = main.o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj.o \
5658
BitInputStream.o dinEXIDatatypesEncoder.o MethodsBag.o \
5759
BitOutputStream.o dinEXIDatatypes.o projectExiConnector.o
5860

61+
ifneq ($(filter ReleaseQCAFlash,$(MAKECMDGOALS)),)
62+
CFLAGS += -Iplcboot -DENABLE_PLCBOOT
63+
CPPFLAGS += -Iplcboot -DENABLE_PLCBOOT
64+
ASFLAGS += -Iplcboot -DENABLE_PLCBOOT
65+
OBJSL += plcboot/plcboot.o plcboot/embedded_images.o plcboot/embedded_images_data.o
66+
endif
67+
5968

6069
OBJS = $(patsubst %.o,obj/%.o, $(OBJSL))
6170
DEPENDS := $(patsubst %.o,obj/%.d, $(OBJSL))
6271
vpath %.c src/ libopeninv/src exi/ ccs/
6372
vpath %.cpp src/ libopeninv/src exi/ ccs/
73+
vpath %.s plcboot/
6474

6575
OPENOCD_BASE = /usr
6676
OPENOCD = $(OPENOCD_BASE)/bin/openocd
@@ -95,6 +105,7 @@ LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
95105
all: directories images
96106
Debug:images
97107
Release: images
108+
ReleaseQCAFlash: images
98109
cleanDebug:clean
99110
images: $(BINARY)
100111
@printf " OBJCOPY $(BINARY).bin\n"
@@ -116,12 +127,19 @@ $(BINARY): $(OBJS) $(LDSCRIPT)
116127

117128
$(OUT_DIR)/%.o: %.c Makefile
118129
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
130+
$(Q)$(MKDIR_P) $(dir $@)
119131
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
120132

121133
$(OUT_DIR)/%.o: %.cpp Makefile
122134
@printf " CPP $(subst $(shell pwd)/,,$(@))\n"
135+
$(Q)$(MKDIR_P) $(dir $@)
123136
$(Q)$(CPP) $(CPPFLAGS) $(EXTRACOMPILERFLAGS) -MMD -MP -o $@ -c $<
124137

138+
$(OUT_DIR)/%.o: %.s Makefile
139+
@printf " AS $(subst $(shell pwd)/,,$(@))\n"
140+
$(Q)$(MKDIR_P) $(dir $@)
141+
$(Q)$(AS) $(ASFLAGS) $(EXTRACOMPILERFLAGS) -MMD -MP -o $@ -c $<
142+
125143
clean:
126144
@printf " CLEAN ${OUT_DIR}\n"
127145
$(Q)rm -rf ${OUT_DIR}

ccs/homeplug.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* Homeplug message handling */
22

33
#include "ccs32_globals.h"
4+
#ifdef ENABLE_PLCBOOT
5+
#include "plcboot.h"
6+
#endif
47

58

69

@@ -509,7 +512,6 @@ void evaluateGetSwCnf(void)
509512
uint8_t i, x;
510513
char strMac[20];
511514
addToTrace(MOD_HOMEPLUG, "[PEVSLAC] received GET_SW.CNF");
512-
numberOfSoftwareVersionResponses+=1;
513515
for (i=0; i<6; i++)
514516
{
515517
sourceMac[i] = myethreceivebuffer[6+i];
@@ -519,6 +521,7 @@ void evaluateGetSwCnf(void)
519521
if ((verLen>0) && (verLen<0x30))
520522
{
521523
char strVersion[200];
524+
bool handledByPlcboot = false;
522525

523526
for (i=0; i<verLen; i++)
524527
{
@@ -530,6 +533,9 @@ void evaluateGetSwCnf(void)
530533
strVersion[i]=x;
531534
}
532535
strVersion[i] = 0;
536+
#ifdef ENABLE_PLCBOOT
537+
handledByPlcboot = plcboot_handle_software_version(strVersion, sourceMac);
538+
#endif
533539
if (Param::GetInt(Param::logging) & MOD_HOMEPLUG) {
534540
sprintf(strMac, "%02x:%02x:%02x:%02x:%02x:%02x", sourceMac[0], sourceMac[1], sourceMac[2], sourceMac[3], sourceMac[4], sourceMac[5]);
535541
printf("For MAC %s ", strMac);
@@ -545,6 +551,13 @@ void evaluateGetSwCnf(void)
545551
OledLine3 = StringVersion.substring(22, 33);
546552
OledLine4 = StringVersion.substring(33, 44);
547553
#endif
554+
if (!handledByPlcboot)
555+
{
556+
/* BootLoader responses start the flashing path and must not be counted as
557+
an operational modem, otherwise the normal SLAC flow would continue in
558+
parallel with the flash sequence. */
559+
numberOfSoftwareVersionResponses+=1;
560+
}
548561
}
549562
}
550563

@@ -837,14 +850,20 @@ static void evaluateGetKeyCnf(void) {}
837850

838851
void evaluateReceivedHomeplugPacket(void)
839852
{
853+
uint16_t mmtype = getManagementMessageType();
854+
840855
if (connMgr_getConnectionLevel()==100) {
841856
/* we have TCP traffic running, so we ignore all homeplug management packets. This
842857
makes us robust against cross-talk from other charging cables.
843858
Discussion here: https://github.com/uhi22/ccs32clara/issues/24 */
844859
addToTrace(MOD_HOMEPLUG, "[HOMEPLUG] Ignoring homeplug message, because high level communication is ongoing.");
845860
return;
846861
}
847-
switch (getManagementMessageType())
862+
#ifdef ENABLE_PLCBOOT
863+
if (plcboot_handle_homeplug_packet(mmtype, myethreceivebuffer, myethreceivebufferLen))
864+
return;
865+
#endif
866+
switch (mmtype)
848867
{
849868
case CM_GET_KEY + MMTYPE_CNF:
850869
evaluateGetKeyCnf();

ccs/qca7000.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
/* Global Defines */
44

5+
#ifdef ENABLE_PLCBOOT
6+
#define MY_SPI_TX_RX_BUFFER_SIZE 1600
7+
#define MY_ETH_TRANSMIT_BUFFER_LEN 1500
8+
#define MY_ETH_RECEIVE_BUFFER_LEN 1500
9+
#else
510
#define MY_SPI_TX_RX_BUFFER_SIZE 1100
611
#define MY_ETH_TRANSMIT_BUFFER_LEN 250
712
#define MY_ETH_RECEIVE_BUFFER_LEN 250
13+
#endif
814

915
#ifdef __cplusplus
1016
extern "C" {

plcboot/embedded_images.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "embedded_images.h"
2+
3+
extern "C" {
4+
extern const uint8_t _binary_softloader_nvm_start[];
5+
extern const uint8_t _binary_softloader_nvm_end[];
6+
extern const uint8_t _binary_firmware_nvm_start[];
7+
extern const uint8_t _binary_firmware_nvm_end[];
8+
extern const uint8_t _binary_pev_pib_start[];
9+
extern const uint8_t _binary_pev_pib_end[];
10+
}
11+
12+
const embedded_images_t *embedded_images(void)
13+
{
14+
static embedded_images_t img;
15+
16+
img.softloader.data = _binary_softloader_nvm_start;
17+
img.softloader.size = (uint32_t)(_binary_softloader_nvm_end - _binary_softloader_nvm_start);
18+
img.firmware.data = _binary_firmware_nvm_start;
19+
img.firmware.size = (uint32_t)(_binary_firmware_nvm_end - _binary_firmware_nvm_start);
20+
img.pib.data = _binary_pev_pib_start;
21+
img.pib.size = (uint32_t)(_binary_pev_pib_end - _binary_pev_pib_start);
22+
23+
return &img;
24+
}

plcboot/embedded_images.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
typedef struct {
6+
const uint8_t *data;
7+
uint32_t size;
8+
} embedded_image_t;
9+
10+
typedef struct {
11+
embedded_image_t softloader;
12+
embedded_image_t firmware;
13+
embedded_image_t pib;
14+
} embedded_images_t;
15+
16+
const embedded_images_t *embedded_images(void);

plcboot/embedded_images_data.s

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Embedded QCA flash images */
2+
3+
.section .rodata
4+
.align 4
5+
6+
.global _binary_softloader_nvm_start
7+
.type _binary_softloader_nvm_start, %object
8+
_binary_softloader_nvm_start:
9+
.incbin "flash/softloader.nvm"
10+
_binary_softloader_nvm_end:
11+
.global _binary_softloader_nvm_end
12+
.type _binary_softloader_nvm_end, %object
13+
14+
.align 4
15+
16+
.global _binary_firmware_nvm_start
17+
.type _binary_firmware_nvm_start, %object
18+
_binary_firmware_nvm_start:
19+
.incbin "flash/firmware.nvm"
20+
_binary_firmware_nvm_end:
21+
.global _binary_firmware_nvm_end
22+
.type _binary_firmware_nvm_end, %object
23+
24+
.align 4
25+
26+
.global _binary_pev_pib_start
27+
.type _binary_pev_pib_start, %object
28+
_binary_pev_pib_start:
29+
.incbin "flash/pev.pib"
30+
_binary_pev_pib_end:
31+
.global _binary_pev_pib_end
32+
.type _binary_pev_pib_end, %object

plcboot/nvm.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
typedef struct __attribute__((packed)) {
6+
uint16_t MajorVersion;
7+
uint16_t MinorVersion;
8+
uint32_t ExecuteMask;
9+
uint32_t ImageNvmAddress;
10+
uint32_t ImageAddress;
11+
uint32_t ImageLength;
12+
uint32_t ImageChecksum;
13+
uint32_t EntryPoint;
14+
uint32_t NextHeader;
15+
uint32_t PrevHeader;
16+
uint32_t ImageType;
17+
uint16_t ModuleID;
18+
uint16_t ModuleSubID;
19+
uint16_t AppletEntryVersion;
20+
uint16_t Reserved0;
21+
uint32_t Reserved[11];
22+
uint32_t HeaderChecksum;
23+
} nvm_header2_t;
24+
25+
#define NVM_NO_NEXT_HEADER 0xFFFFFFFFu
26+
27+
#define NVM_IMAGE_MEMCTL 0x0007u
28+
#define NVM_IMAGE_FIRMWARE 0x0004u
29+
#define NVM_IMAGE_SOFTLOADER 0x000Bu
30+
#define NVM_IMAGE_PIB 0x000Fu

0 commit comments

Comments
 (0)