Skip to content

Add support for IAR version 8.x #4938

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

Merged
merged 10 commits into from
Sep 11, 2017
1 change: 1 addition & 0 deletions TESTS/mbed_drivers/stl_features/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <queue>
#include <map>
#include <math.h>
#include <functional>

using namespace utest::v1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static bool set_CNMI(ATCmdParser *at)
// New SMS indication configuration
// set AT+CMTI=[mode, index] , 0 PDU mode, 1 text mode
// Multiple URCs for SMS, i.e., CMT, CMTI, UCMT, CBMI, CDSI as DTE could be following any of these SMS formats
bool success = at->send("AT+CNMI=2,"CTX) && at->recv("OK");
bool success = at->send("AT+CNMI=2," CTX) && at->recv("OK");
return success;
}

Expand Down Expand Up @@ -141,7 +141,7 @@ static void CMT_URC(ATCmdParser *at)

static bool set_atd(ATCmdParser *at)
{
bool success = at->send("ATD*99***"CTX"#") && at->recv("CONNECT");
bool success = at->send("ATD*99***" CTX"#") && at->recv("CONNECT");

return success;
}
Expand Down Expand Up @@ -469,7 +469,7 @@ nsapi_error_t PPPCellularInterface::setup_context_and_credentials()
#endif
success = _at->send("AT"
"+FCLASS=0;" // set to connection (ATD) to data mode
"+CGDCONT="CTX",\"%s\",\"%s%s\"",
"+CGDCONT=" CTX",\"%s\",\"%s%s\"",
pdp_type, auth, _apn
)
&& _at->recv("OK");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ typedef struct _ARM_CFSTORE_STATUS {
}while(0)
#endif

#if defined __MBED__ && defined TOOLCHAIN_IAR
#if defined __MBED__ && defined __ICCARM__
/** @brief Helper macro to swap 2 handles, which is useful for the Find() idiom. */
/* note, memory barriers may be required in the following implementation */
#define CFSTORE_HANDLE_SWAP(__a_HaNdLe, __b_HaNdLe) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* FlashJournal_t. The caller will only allocate a FlashJournal_t and expect the
* Sequential Strategy to reuse that space for a SequentialFlashJournal_t.
*/
#ifndef TOOLCHAIN_IAR
#ifndef __ICCARM__
typedef char AssertStorageVolumeManagerMaxVolumesIsSane[(((MAX_VOLUMES) > 0) && ((MAX_VOLUMES) <= 8)) ? 0:-1];
#endif

Expand Down
7 changes: 5 additions & 2 deletions platform/mbed_retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ std::FILE *mbed_fdopen(FileHandle *fh, const char *mode)
}

int mbed_getc(std::FILE *_file){
#if defined (__ICCARM__)
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ < 8000000)
/*This is only valid for unbuffered streams*/
int res = std::fgetc(_file);
if (res>=0){
Expand All @@ -858,7 +858,7 @@ int mbed_getc(std::FILE *_file){
}

char* mbed_gets(char*s, int size, std::FILE *_file){
#if defined (__ICCARM__)
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ < 8000000)
/*This is only valid for unbuffered streams*/
char *str = fgets(s,size,_file);
if (str!=NULL){
Expand All @@ -884,6 +884,9 @@ extern "C" WEAK void __iar_file_Mtxinit(__iar_Rmtx *mutex) {}
extern "C" WEAK void __iar_file_Mtxdst(__iar_Rmtx *mutex) {}
extern "C" WEAK void __iar_file_Mtxlock(__iar_Rmtx *mutex) {}
extern "C" WEAK void __iar_file_Mtxunlock(__iar_Rmtx *mutex) {}
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ >= 8000000)
extern "C" WEAK void *__aeabi_read_tp (void) { return NULL ;}
#endif
#elif defined(__CC_ARM)
// Do nothing
#elif defined (__GNUC__)
Expand Down
11 changes: 9 additions & 2 deletions rtos/TARGET_CORTEX/mbed_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@
#include "cmsis_os2.h"
#include "mbed_toolchain.h"
#include "mbed_error.h"

#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ >= 8000000)
#include <DLib_Threads.h>
#endif
/* Heap limits - only used if set */
extern unsigned char *mbed_heap_start;
extern uint32_t mbed_heap_size;
Expand Down Expand Up @@ -552,7 +554,7 @@ void __rtos_env_unlock( struct _reent *_r )

#endif

#if defined(TOOLCHAIN_IAR) /******************** IAR ********************/
#if defined(__ICCARM__) /******************** IAR ********************/

extern void* __vector_table;
extern int __low_level_init(void);
Expand All @@ -574,9 +576,14 @@ void pre_main(void)
singleton_mutex_attr.cb_mem = &singleton_mutex_obj;
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);

#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ >= 8000000)
__iar_Initlocks();
#endif

if (low_level_init_needed) {
__iar_dynamic_initialization();
}

mbed_main();
main();
}
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ emac_interface_t *wlan_emac_init_interface()
{

if (_emac == NULL) {
_emac = new emac_interface_t();
_emac = (emac_interface_t*) malloc(sizeof(emac_interface_t));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use new or error in the case it fails, not print

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sg- Everywhere in file print statements are used instead error, I can add that as bug and get it fix in new PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new would have failed as assert but malloc won't. That is the change in behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, @deepikabhavnani, this was the issue with const members right?

@sg-, the emac_interface_t as written can't be default constructed in c++ (here). The const member (ops) must be constructed but the emac_interface_t class doesn't have a constructor to initialize the member. Since the emac_api header is also included by C files, we can't add a constructor. C supports struct initializers for this case, but C++ relies on constructors.

We can either remove the const or allocate with malloc. We could change the error print to assert.

if (_emac == NULL) {//new emac_interface_t fail
printf("emac initialization failed\r\n");
return NULL;
Expand Down