ARM Semihosting console not work in Example

Sysprogs forums Forums VisualGDB ARM Semihosting console not work in Example

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #6703
    andrei0686
    Participant

    Hello.
    I tried to make an example, and he did not work. The console does not output function printf.
    http://visualgdb.com/tutorials/arm/semihosting/

    I use:

    Visual Studio 2013

    VisualGDB 5.0 Beta 4

     

    • This topic was modified 9 years, 3 months ago by andrei0686.
    • This topic was modified 9 years, 3 months ago by andrei0686.
    #6730
    support
    Keymaster

    Which toolchain are you using? The Sysprogs ARM toolchain should enable semihosting by default. The GNUARM toolchain needs enabling it by specifying a spec file. The latest VisualGDB 5.0 beta 4 can automatically detect the GNUARM toolchain and provide a GUI option for enabling semihosting.

    #6762
    andrei0686
    Participant

    I use arm-eabi GCC version 4.9.2 GDB version 7.8.1.

    Property: Virtual ARM console support i set Enabled.

    board: stm3240G-eval.

    LED connected to GPIOG pin 6 blinks.

    ARM semihosting console is clear, just a black screen.

    this code:

    #include <stm32f4xx_hal.h>
    #include <stdio.h>
    
    #ifdef __cplusplus
    extern "C"
    #endif
    void SysTick_Handler(void)
    {
        HAL_IncTick();
        HAL_SYSTICK_IRQHandler();
    }
    
    int main(void)
    {
        HAL_Init();
    
        __GPIOG_CLK_ENABLE();
        GPIO_InitTypeDef GPIO_InitStructure;
    
        GPIO_InitStructure.Pin = GPIO_PIN_6;
    
        GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
        GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
        GPIO_InitStructure.Pull = GPIO_NOPULL;
        HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
    
        for (;;)
        {
            printf("Hello");
            HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_SET);
            HAL_Delay(500);
            HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);
            HAL_Delay(500);
        }
    }
    #6771
    support
    Keymaster

    Please try calling initialise_monitor_handles():

    #include  <stdio.h>
    
    extern "C" void initialise_monitor_handles(void);
    
    int main(void)
    {
        initialise_monitor_handles();
        printf("test\n");
        return 0;
    }
    #6777
    andrei0686
    Participant

    Nothing changed. The console is empty.
    Small changes in configuration: I downloaded VisualGDB 5.0 Beta 5. Nothing changed.

    this code:

    #include <stm32f4xx_hal.h>;
    #include <stdio.h>;

    #ifdef __cplusplus
    extern “C”
    #endif
    void SysTick_Handler(void)
    {
    HAL_IncTick();
    HAL_SYSTICK_IRQHandler();
    }

    extern “C” void initialise_monitor_handles(void);

    int main(void)
    {
    initialise_monitor_handles();
    printf(“hello-2”);

    HAL_Init();

    __GPIOG_CLK_ENABLE();
    GPIO_InitTypeDef GPIO_InitStructure;

    GPIO_InitStructure.Pin = GPIO_PIN_6;

    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStructure.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);

    for (;;)
    {
    printf(“hello”);
    HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_SET);
    HAL_Delay(500);
    HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);
    HAL_Delay(500);
    }
    }

    • This reply was modified 9 years, 3 months ago by andrei0686.
    • This reply was modified 9 years, 3 months ago by andrei0686.
    • This reply was modified 9 years, 3 months ago by andrei0686.
    #6803
    support
    Keymaster

    Is it the toolchain that came with VisualGDB (http://gnutoolchains.com/arm-eabi/) or have you installed it separately? Could you attach your stm32.xml file that shows the current toolchain configuration?

    #6814
    andrei0686
    Participant

    I just downloaded and installed it VisualGDB, it is automatically downloaded toolchain . I do not have installed separately.

    the contents of the file stm32.xml:

    <?xml version=”1.0″?>
    <EmbeddedProfile xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
    <ToolchainID>com.visualgdb.arm-eabi</ToolchainID>
    <BspID>com.sysprogs.arm.stm32</BspID>
    <BspVersion>3.2</BspVersion>
    <McuID>STM32F407IG</McuID>
    <MCUDefinitionFile>STM32F4xxxx/DeviceDefinitions/stm32f407xx.xml</MCUDefinitionFile>
    <MCUProperties>
    <Entries>
    <KeyValue>
    <Key>com.sysprogs.bspoptions.primary_memory</Key>
    <Value>flash</Value>
    </KeyValue>
    <KeyValue>
    <Key>com.sysprogs.bspoptions.arm.floatmode</Key>
    <Value>-mfloat-abi=soft</Value>
    </KeyValue>
    <KeyValue>
    <Key>com.sysprogs.toolchainoptions.arm.libctype</Key>
    <Value />
    </KeyValue>
    <KeyValue>
    <Key>com.sysprogs.toolchainoptions.arm.compactcpp</Key>
    <Value>compactcpp</Value>
    </KeyValue>
    <KeyValue>
    <Key>com.sysprogs.toolchainoptions.arm.libnosys</Key>
    <Value />
    </KeyValue>
    </Entries>
    </MCUProperties>
    <BSPSourceFolderName>Device-specific files</BSPSourceFolderName>
    <MCUMakFile>stm32.mak</MCUMakFile>
    <ReferencedFrameworks>
    <string>com.sysprogs.arm.stm32.hal</string>
    </ReferencedFrameworks>
    <FrameworkProperties>
    <Entries />
    </FrameworkProperties>
    </EmbeddedProfile>

    #6831
    StrongArm
    Participant

    Visual Studio 2015 Community Edition
    arm-eabi GCC version 4.9.2 VisualGDB 5.0 Beta 5

    Just evaluating VisualGDB i also had a problem with Semihosting not working.
    After testing different configurations i got it working by changing the library from NewLib-nano to default.

    Using Semihosting changes the startup time for the debugger drastically from ~4 seconds to 15-20 seconds.The code memory overhead using the regular printf function for Semihosting on a STM32L0 device is just to much.
    Would it be possible to implement a simple string output function with Semihosting and leaving the formatting up to the user?

    Regards from Austria

    #6833
    support
    Keymaster

    Hi,

    Normally the standard C library only flushes the printf() output when a newline is encountered, i.e. printf(“test”) will not print anything, but printf(“test\n”) will.

    You can override this by either calling fflush(stdout) after printf() or adding the following call before printf():

    setvbuf(stdout, NULL, _IONBF, 0);

    If you are using newlib-nano, please add “–specs=rdimon.specs” to LDFLAGS to enable newlib-nano semihosting implementation.

    If you want to do the formatting on the computer instead of the device, you would need to make a custom semihosting call handler plugin for VisualGDB. If you believe it is worth the effort, please let us know so that we could extend our SDK with API for implementing such plugins.

     

    #6835
    andrei0686
    Participant

    Thanks for the help, but unfortunately my trial version is over and I can not check your recommendations.

    #6838
    StrongArm
    Participant

    Hi Bazis,
    tried as you succested:

    >If you are using newlib-nano, please add “–specs=rdimon.specs” to LDFLAGS to enable newlib-nano semihosting implementation.

    Adding this option to the LDFLAGS disables the breakpoints in the program and you get a warning in the GDB console:
    “Warning: could not set a breakpoint on main. ‘Step into new instance’ will not work.”
    Verified this behavior with a NUCLEO-L053R8 and Discovery 32F429IDISCOVERY board.

    >If you want to do the formatting on the computer instead of the device, you would need to make a custom semihosting call handler plugin for VisualGDB.
    >If you believe it is worth the effort, please let us know so that we could extend our SDK with API for implementing such plugins.

    I believe that this API would be only usefull for a part of people working with some smaller devices where all the UARTS are already used.
    Would it not be less effort to simply redirect the stream to a virtual com port on the PC?

    Sorry for going off topic now!

    But what kind of API would really be extrem usfull for a lot of people (at least i think so -):
    Make an API for the Live Variables!
    Add the type of a fixed length buffer to the variables and you get a perfect tool to run most of the needed test cases without changing the source code on the device(s).
    You can do all together in one VS solution and dont’t have to fiddle around with some external gdb in asynchron mode.

     

    Best regards from Austria

    #6840
    support
    Keymaster

    Hi,

    Looks like the forum engine converted the dash incorrectly. Here is the correct option:

    --specs=rdimon.specs

    Please also ensure that the “provide default implementations for syscalls” checkbox is not checked.

    Not 100% sure what you meant about fixed-length buffer API. Could you perhaps provide an example of a task you want to accomplish with it?

    #6841
    StrongArm
    Participant

    Hi,

    -specs=rdimon.specs is correct, you can’t enter –specs=rdimon.specs into theLDFLAGS field.
    You cannot uncheck “provide default implementations for syscalls” because _write,_close,_fstat usw.
    becomes undefined when using printf with Newlib-nano.

    >Not 100% sure what you meant about fixed-length buffer API. Could you perhaps provide an example of a task you want to accomplish with it?

    I was talking about an API for the Live Variables. You have already defined the types from 8-bit unsigned to 64-bit floating point. Here i am missing a tpye to access to a fixed length buffer.

    char buff[20] = “Hello world”;                         //fixed length buffer var on the embedded system, length = 20, no string variable
    int count = 12345;                                                //int var on the embedded system

    To show the Live Variables in the “Live Variable window” i can enter into the expression field
    “count” and the value shown is “12345” or
    “buff[0]” – value “0x48”
    “buff[1]” – value “0x65”
    “buff[2]” – value “0x6c” ……
    This is ok when i want to show the variables only in the graph window.

    With an Live Variable API I would like to do following:
    char livebuff[20];
    int  liveint;

    readLiveVariable(count,liveint);
    readLiveVariable(buff,livebuff,20);     //tranfer 20 bytes from the embedded system variabel buff
    writeLiveVariable(count,i);
    writeLiveVariable(buff,livebuff,20);   //send 20 bytes to the embedded system system variable buff

    As I already said, getting programatical access to the Live Variables via an API would be really great – for example – writing  test software for embedded systems. Different test cases can be programmed on the PC and the embedded software running under the debugger stays untouched.

    Best regards

    P.S. how can I use the code window in this forum?

    • This reply was modified 9 years, 2 months ago by StrongArm.
    #6845
    support
    Keymaster

    Hi,

    Not sure why the double dash did not work for you, but it should be double. Here is a screenshot:

    Together with unchecking the “provide default implementations” field (that sets –specs=nosys.specs), this results in the following build command line:

    F:\SysGCC\arm-eabi/bin/arm-eabi-g++.exe -o Debug/stm32f4test.elf -Wl,-gc-sections --specs=rdimon.specs  ... -lcompactcpp    -Wl,--end-group

    If the GUI does not work, you can try manually modifying LDFLAGS in debug.mak.

    Regarding live variables. As a quick fix, if you are using OpenOCD, you can try connecting to port 4444 and sending OpenOCD commands (e.g. mdw <address> to read a DWORD), however you cannot do this if you are using live variables, as VisualGDB uses the same interface.

    As a long-term solution, we are actually planning to add support for running tests with VisualGDB, so we could make a much higher-level interface. We would rather provide a framework for defining test functions with test asserts in your code (that will be normally ignored) and then add a special mode where VisualGDB will build a binary with the tests enabled and run the given subset of tests. Would that be more useful than just live variables API?

    #6847
    StrongArm
    Participant

    Hi Bazis,
    first of all, thank you for the great support here, even for people only evaluating VisualGDB!!!
    Have to change this – where is the buy button -:)

    Your last post solved all the strange problems I had.
    Becoming old and blind is not funny! As usual i used a comma between the flags, so i added “,- specs =rdmon.sys”.Try it, the GUI does not complain, but you get all the troubles i had!
    Whatever, problem solved, semihosting working with Newlib-nano.

    >Regarding live variables.As a quick fix….
    No quick fix needed, the development project (medical technology) I got the order for, has a time frame of 24 month..
    Just looking for all the tools I need.
    I see three different possibilties to run tests without adding some test functions to the code.
    (During the devolopment adding test functions is not the problem, the problem starts when your code gets “frozen” and all debug functions are removed)

    1.) Using GDB and OpenOCD direct to access the final software on the devices.
    2.) Using your VisualGDBExtensibility Interface – seems to be able to do the job.
    The only example i could find was the tuturial “Debugging Embedded Threads with VisualGDB”, tried it, worked.
    But,… there is nowhere a documentation of all the Interfaces.
    3.) Using the new Visual Studio MI Debug Engine.

    Best regards

     

     

Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.