Skip to content

Fixes and enhancements to setup, config, build, and run processes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IoT.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ solution:
packs:
- pack: ARM::CMSIS
- pack: ARM::CMSIS-Driver
- pack: ARM::CMSIS-FreeRTOS@10.4.6
- pack: ARM::CMSIS-FreeRTOS@10.5.1
- pack: ARM::mbedTLS@1.7.0
- pack: AWS::backoffAlgorithm@1.0.0-Beta
- pack: AWS::coreMQTT@1.1.0-Beta
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ case $1 in
cbuild mqtt_pub_sub/AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300.cprj -c
;;
*)
csolution convert -s IoT.csolution.yml -c AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300
csolution convert -s IoT.csolution.yml -c AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300
cp mqtt_pub_sub/RTE/RTOS/FreeRTOSConfig.h RTE/RTOS/FreeRTOSConfig.h
cbuild mqtt_pub_sub/AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300.cprj
;;
esac
56 changes: 56 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#! /bin/bash

d=$(dirname $0)
c=$d/credentials
p=$$

echo - Configure AWS API credentials
aws configure

f_cred=$d/mqtt_pub_sub/config_files/aws_clientcredential_keys.h
f_config=$d/mqtt_pub_sub/config_files/demo_config.h


echo - Create thing credentials
key_prv=$c/thing.prv.$p.key
key_pub=$c/thing.pub.$p.key
crt_509=$c/thing.crt.$p.crt

mkdir -p $c

aws iot create-keys-and-certificate \
--set-as-active \
--certificate-pem-outfile $crt_509 \
--public-key-outfile $key_pub \
--private-key-outfile $key_prv > $c/certificate.$p.config

sed -e 's/^/"/g' -e 's/$/\\n"\\/g' -e '$ s/.$//' $crt_509 > $crt_509.block
sed -e 's/^/"/g' -e 's/$/\\n"\\/g' -e '$ s/.$//' $key_prv > $key_prv.block

sed -e 's/keyCLIENT_CERTIFICATE_PEM ""/keyCLIENT_CERTIFICATE_PEM/' \
-e "/keyCLIENT_CERTIFICATE_PEM/r $crt_509.block" $f_cred | \
sed -e ':a;N;$!ba;s/keyCLIENT_CERTIFICATE_PEM\n/keyCLIENT_CERTIFICATE_PEM /g' > \
/tmp/k$p && mv -f /tmp/k$p $f_cred

sed -e 's/keyCLIENT_PRIVATE_KEY_PEM ""/keyCLIENT_PRIVATE_KEY_PEM/' \
-e "/keyCLIENT_PRIVATE_KEY_PEM/r $key_prv.block" $f_cred | \
sed -e ':a;N;$!ba;s/keyCLIENT_PRIVATE_KEY_PEM\n/keyCLIENT_PRIVATE_KEY_PEM /g' > \
/tmp/k$p && mv -f /tmp/k$p $f_cred

clientid=$(hostname | sed -e 's/-//g')-$p
endpoint=$(aws iot describe-endpoint --endpoint-type iot:Data-ATS --output text)
certificate_arn=$(jq -r .certificateArn $d/credentials/certificate.$p.config)
certificate_id=$(jq -r .certificateId $d/credentials/certificate.$p.config)

aws iot create-thing --thing-name $clientid > $c/thing.$p.config
aws iot attach-thing-principal \
--thing-name $clientid \
--principal $certificate_arn
aws iot attach-policy \
--policy-name dev_policy \
--target $certificate_arn

sed -i -e "s/^#define democonfigCLIENT_IDENTIFIER.*/#define democonfigCLIENT_IDENTIFIER \"$clientid\"/" $f_config
sed -i -e "s/^\s#define democonfigMQTT_BROKER_ENDPOINT.*/#define democonfigMQTT_BROKER_ENDPOINT \"$endpoint\"/" $f_config


26 changes: 9 additions & 17 deletions install_cpacks.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
#!/bin/bash
cpackget -q pack add -a ARM::CMSIS-Driver
cpackget -q pack add -a ARM::CMSIS-FreeRTOS@10.4.6
cpackget -q pack add -a ARM::mbedTLS@1.7.0
cpackget -q pack add -a AWS::backoffAlgorithm@1.0.0-Beta
cpackget -q pack add -a AWS::coreMQTT@1.1.0-Beta
cpackget -q pack add -a AWS::coreMQTT_Agent@1.0.1-Beta
cpackget -q pack add -a AWS::corePKCS11@3.0.0-Beta
cpackget -q pack add -a AWS::FreeRTOS-Plus-TCP@2.3.2-Beta
cpackget -q pack add -a Arm-Packs::PKCS11
cpackget -q pack add -a MDK-Packs::IoT_Socket
cpackget -q pack add -a Keil::V2M-MPS2_CMx_BSP@1.8.0
cpackget -q pack add -a ARM::V2M_MPS3_SSE_300_BSP@1.2.0
cpackget -q pack add -a NXP::MIMXRT1052_DFP@13.1.0
cpackget -q pack add -a NXP::EVKB-IMXRT1050_BSP@13.1.0
cpackget -q pack add -a Keil::IMXRT1050-EVKB_BSP@1.0.0
cpackget -q pack add -a Keil::iMXRT105x_MWP@1.4.0
#! /bin/bash
d=$(dirname $0)
c="cpackget -q pack add -a"
# Use the single source of truth to get packages
plist=$(grep pack: $d/IoT.csolution.yml | sed -e 's/\s//g' -e s'/-pack://g')

for pkg in $plist; do
$c $pkg
done
1 change: 1 addition & 0 deletions mqtt_pub_sub/RTE/RTOS/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,5 @@ void vLoggingPrintf( const char * pcFormat, ... );
#define configHEAP_REGION0_ADDR 0
#define configHEAP_REGION0_SIZE 0x1E000

#define configENABLE_MVE 1
#endif /* FREERTOS_CONFIG_H */
7 changes: 6 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

buildtype=Release
image=AWS_MQTT_PubSub_Demo.$buildtype+AVH_MPS3_Corstone-300.axf
target=./out/AWS_MQTT_PubSub_Demo/AVH_MPS3_Corstone-300/$buildtype/$image

VHT_MPS3_Corstone_SSE-300 -C mps3_board.visualisation.disable-visualisation=1 \
-C mps3_board.telnetterminal0.start_telnet=0 \
-C mps3_board.uart0.out_file=- \
-a mqtt_pub_sub/AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300_OutDir/AWS_MQTT_PubSub_Demo.Release+AVH_MPS3_Corstone-300.axf
-a $target