Skip to content

Commit

Permalink
Merge branch 'devcontainer-ci-build' into fixs-f7
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion committed Aug 31, 2023
2 parents cc19be8 + 40f454a commit 0dd1484
Show file tree
Hide file tree
Showing 29 changed files with 815 additions and 373 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/build-chibios-target.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build for a ChibiOS target

on:
push:
pull_request:
release:
types:
- created
workflow_dispatch:

jobs:
build-target:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup config
run: |
# Apply config templates
pushd config
mv user-prefs.TEMPLATE.json user-prefs.json
mv user-tools-repos.TEMPLATE.json user-tools-repos.json
sed -i -- 's|"name": "user-tools-repos-container"|"name": "user-tools-repos"|g' user-tools-repos.json
popd
# required fixes for current devcontainer
pushd .devcontainer
# target the chibios container for a quicker build
sed -i -- 's|"dockerFile": "Dockerfile.All"|"dockerFile": "Dockerfile.ChibiOS"|g' devcontainer.json
# remove unsupported commands
sed -i -- 's|"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",|//"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",|g' devcontainer.json
sed -i -- 's|"source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind"|//"source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind",|g' devcontainer.json
popd
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Device MinSizeRel Firmware
uses: devcontainers/[email protected]
with:
# The ChibiOS container
# imageName: ghcr.io/nanoframework/dev-container-chibios
cacheFrom: ghcr.io/nanoframework/dev-container-chibios
push: never
runCmd: |
# TODO: if we want to improve: https://code.visualstudio.com/remote/advancedcontainers/environment-variables
cmake --preset=ST_STM32F769I_DISCOVERY -DCMAKE_BUILD_TYPE=MinSizeRel
cmake --build build -j4
- name: Upload MinSizeRel artifact
uses: actions/upload-artifact@v3
with:
name: Firmware MinSizeRel
path: |
./build/*.map
./build/*.elf
./build/*.hex
./build/*.bin
./build/*.dfu
- name: Build Device Debug Firmware
uses: devcontainers/[email protected]
with:
# The ChibiOS container
cacheFrom: ghcr.io/nanoframework/dev-container-chibios
push: never
runCmd: |
# TODO: if we want to improve: https://code.visualstudio.com/remote/advancedcontainers/environment-variables
cmake --preset=ST_STM32F769I_DISCOVERY -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j4 # -v
- name: Upload Debug artifact
uses: actions/upload-artifact@v3
with:
name: Firmware Debug
path: |
./build/*.map
./build/*.elf
./build/*.hex
./build/*.bin
./build/*.dfu
12 changes: 6 additions & 6 deletions src/CLR/CorLib/corlib_native_System_Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ HRESULT Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__S
char *outArray = NULL;
char *outArrayWitLineBreak = NULL;
uint8_t *inArrayPointer = NULL;
uint8_t lineBreakCount;
int32_t lineBreakCount;
uint16_t offsetIndex = 0;
uint8_t count = 0;
uint16_t result;
Expand Down Expand Up @@ -727,18 +727,18 @@ HRESULT Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY
#if (SUPPORT_ANY_BASE_CONVERSION == TRUE)

CLR_RT_HeapBlock_String *inString = NULL;
size_t outputLength;
uint32_t outputLength;
char *outArray = NULL;
CLR_UINT8 *returnArray;
uint16_t result;
size_t length;
uint32_t length;

inString = stack.Arg0().DereferenceString();
FAULT_ON_NULL(inString);

FAULT_ON_NULL_ARG(inString->StringText());

length = (size_t)hal_strlen_s(inString->StringText());
length = hal_strlen_s(inString->StringText());

// estimate output length
outputLength = length / 4 * 3;
Expand All @@ -755,8 +755,8 @@ HRESULT Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY
// need to tweak the parameter with the output length because it includes room for the terminator
result = mbedtls_base64_decode(
(unsigned char *)outArray,
(outputLength + 1),
&outputLength,
(size_t)(outputLength + 1),
(size_t *)&outputLength,
(const unsigned char *)inString->StringText(),
length);

Expand Down
29 changes: 16 additions & 13 deletions src/CLR/CorLib/corlib_native_System_Number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,36 @@ int Library_corlib_native_System_Number::DoPrintfOnDataType(char *buffer, char *
switch (dataType)
{
case DATATYPE_I1:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s1);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s1);
break;
case DATATYPE_U1:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u1);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u1);
break;
case DATATYPE_I2:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s2);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s2);
break;
case DATATYPE_U2:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u2);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u2);
break;
case DATATYPE_I4:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s4);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().s4);
break;
case DATATYPE_U4:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u4);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().u4);
break;
case DATATYPE_I8:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, (CLR_INT64_TEMP_CAST)value->NumericByRef().s8);
ret = (int)(int)
snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, (CLR_INT64_TEMP_CAST)value->NumericByRef().s8);
break;
case DATATYPE_U8:
ret =
ret = (int)
snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, (CLR_UINT64_TEMP_CAST)value->NumericByRef().u8);
break;
case DATATYPE_R4:
ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().r4);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, value->NumericByRef().r4);
break;
case DATATYPE_R8:
ret =
ret = (int)
snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, (CLR_DOUBLE_TEMP_CAST)value->NumericByRef().r8);
break;
default:
Expand All @@ -125,7 +126,9 @@ int Library_corlib_native_System_Number::DoPrintfOnDataType(char *buffer, char *

// assure string valid even in cases when nothing was written
if (ret >= 0)
{
buffer[ret] = 0;
}

return ret;
}
Expand Down Expand Up @@ -550,11 +553,11 @@ int Library_corlib_native_System_Number::Format_G(

if (formatChar == 'g')
{
ret += snprintf(&buffer[ret], FORMAT_RESULT_BUFFER_SIZE - ret, "e%+.2d", exponent);
ret += (int)snprintf(&buffer[ret], FORMAT_RESULT_BUFFER_SIZE - ret, "e%+.2d", exponent);
}
else
{
ret += snprintf(&buffer[ret], FORMAT_RESULT_BUFFER_SIZE - ret, "E%+.2d", exponent);
ret += (int)snprintf(&buffer[ret], FORMAT_RESULT_BUFFER_SIZE - ret, "E%+.2d", exponent);
}
}
}
Expand Down Expand Up @@ -845,7 +848,7 @@ int Library_corlib_native_System_Number::Format_E(char *buffer, CLR_RT_HeapBlock

snprintf(formatStr, FORMAT_FMTSTR_BUFFER_SIZE, "%%.%d%c", precision, formatChar);

ret = snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, copyValue);
ret = (int)snprintf(buffer, FORMAT_RESULT_BUFFER_SIZE, formatStr, copyValue);

if (ret > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLR/Core/CLR_RT_Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static CLR_UINT32 s_TotalAllocated;

CLR_RT_MemoryRange s_CLR_RT_Heap = {0, 0};

static int s_PreHeapInitIndex = 0;
static size_t s_PreHeapInitIndex = 0;

////////////////////////////////////////////////////////////

Expand Down
10 changes: 5 additions & 5 deletions src/CLR/Core/CLR_RT_RuntimeMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@

//--//

size_t LinkArraySize()
uint32_t LinkArraySize()
{
return (PLATFORM_DEPENDENT_ENTRY_SIZE + PLATFORM_DEPENDENT_HASH_TABLE_SIZE);
}
size_t LinkMRUArraySize()
uint32_t LinkMRUArraySize()
{
return (PLATFORM_DEPENDENT_ENTRY_SIZE + 1);
}
size_t PayloadArraySize()
uint32_t PayloadArraySize()
{
return PLATFORM_DEPENDENT_ENTRY_SIZE;
}
#ifndef NANOCLR_NO_IL_INLINE
size_t InlineBufferCount()
uint32_t InlineBufferCount()
{
return PLATFORM_DEPENDENT_INLINE_BUFFER_SIZE;
}
Expand All @@ -141,7 +141,7 @@ unsigned int

//--//

size_t InterruptRecords()
uint32_t InterruptRecords()
{
return PLATFORM_DEPENDENT_INTERRUPT_RECORDS;
}
Expand Down
21 changes: 18 additions & 3 deletions src/CLR/Core/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,28 @@ CLR_RT_HeapBlock *CLR_RT_EventCache::Extract_Node_Bytes(CLR_UINT32 dataType, CLR
CLR_RT_HeapBlock *CLR_RT_EventCache::Extract_Node(CLR_UINT32 dataType, CLR_UINT32 flags, CLR_UINT32 blocks)
{
NATIVE_PROFILE_CLR_CORE();

#if defined(NANOCLR_FORCE_GC_BEFORE_EVERY_ALLOCATION)
return g_CLR_RT_ExecutionEngine.ExtractHeapBlocksForEvents(dataType, flags, blocks);
#else
if (blocks > 0 && blocks < c_maxFastLists)
return Extract_Node_Fast(dataType, flags, blocks);

#if !defined(BUILD_RTM) || defined(VIRTUAL_DEVICE)
if (g_CLR_RT_ExecutionEngine.m_fPerformGarbageCollection)
{
return g_CLR_RT_ExecutionEngine.ExtractHeapBlocksForEvents(dataType, flags, blocks);
}
else
return Extract_Node_Slow(dataType, flags, blocks);
#endif
{
if (blocks > 0 && blocks < c_maxFastLists)
{
return Extract_Node_Fast(dataType, flags, blocks);
}
else
{
return Extract_Node_Slow(dataType, flags, blocks);
}
}
#endif
}

Expand Down
Loading

0 comments on commit 0dd1484

Please sign in to comment.