Can the UART RX/TX pins be also read as GPIO input pins

Greetings,

We are using the NCS for the development of a new product with a custom board based on the nRF52840 MCU.

First, we would like to use the Serial DFU feature to update the firmware over UART. I have found and will be implementing this guide for that. Please confirm that this is indeed correct.

Second we want to also use the same lines(RX/TX) as GPIOs (inputs) and read their status. What way would you suggest going about this? I have found this suggestion usefull (connecting the TX/RX lines to two other available GPIO pins to also read the level of the TX/RX lines) as we will not be using the UART interface and reading the same lines simultaneously.

What are your thoughts and suggestions on implementing this? Will connecting two other GPIO pins on the RX/TX lines cause issues to the UART even if we do not read the pins while the UART interface is in use?

Thank you very much and I look forward to hearing from you!

Best regards,

Stavros

  • Hi Hung,

    Thank you very much for your imediate response!

    I am trying to add the serial dfu functionality described in this guide to an application based on the hello_world sample(with no modifications) on our custom board(before tryng it with our actual custom application).

    I have succesfully completed the procedure on a nRF52840-DK but when I specify our custom board as the target(by switching just the build configuration, for the same source files and prj.config files) instead of the DK I get the following error when I try to pristine build:

    warning: UART_INTERRUPT_DRIVEN (defined at boards/shields\sparkfun_sara_r4\Kconfig.defconfig:24, boards/shields\wnc_m14a2a\Kconfig.defconfig:17, soc/arm\quicklogic_eos_s3\Kconfig.defconfig:17, drivers/serial/Kconfig:72) has direct dependencies (NETWORKING && SHIELD_SPARKFUN_SARA_R4) || (NETWORKING && SHIELD_WNC_M14A2A) || (SERIAL && SOC_EOS_S3) || (SERIAL_SUPPORT_INTERRUPT && SERIAL) with value n, but is currently being y-selected by the following symbols:
     - UART_MCUMGR (defined at drivers/console/Kconfig:190), with value y, direct dependencies CONSOLE (value: y), and select condition CONSOLE (value: y)
    
    error: Aborting due to Kconfig warnings
    
    CMake Error at C:/ncs/v2.1.0/zephyr/cmake/modules/kconfig.cmake:293 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v2.1.0/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
      C:/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:5 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.1.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\ncs\toolchains\v2.1.0\opt\bin\python.exe' '-Bc:\ncs\feel_v2_fw\serial_dfu_hello_world\build_1' -GNinja -DBOARD=feel_v2_evb_v1_0_0 -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=c:/ncs;c:/ncs/feel_v2_fw/feel_v2_fw;c:/ncs/feel_v2_fw/feel_v2_fw/src' -DCONF_FILE:STRING=c:/ncs/feel_v2_fw/serial_dfu_hello_world/prj.conf '-Sc:\ncs\feel_v2_fw\serial_dfu_hello_world'

    The configuration options that the guide instructed to add worked succesfully when the build configuration selected was the nRF52840DK, so they should be correct.

    Am I missing something that should be added other that the configuration mentioned on the guide (maybe in the .dts of our custom board) because everything else is the same and works when I change to the nRD52840DK Build Configuration.

    Also a followup question regarding this approach of DFU process using SMPSVR. Will I be able to use the same UART that the DFU process uses for regular communication and data exchange with other ICs,MCUs etc.??

    Thank you very much.

    Regards

  • Hi Stavros, 
    As mentioned in the log: 

    warning: UART_INTERRUPT_DRIVEN ...is currently being y-selected by the following symbols:
    - UART_MCUMGR (defined at drivers/console/Kconfig:190), with value y, direct dependencies CONSOLE (value: y), and select condition CONSOLE (value: y)

    This meant sparkfun_sara_r4 board configuration has select UART_INTERRUPT_DRIVEN =n but UART_MCUMGR (MCUBOOT SMP)is selecting that symbol as y. I'm not very familiar with the sparkfun shield, but you may want to figure out how to change it to select UART_INTERRUPT_DRIVEN =y. 

    clockis said:
    Also a followup question regarding this approach of DFU process using SMPSVR. Will I be able to use the same UART that the DFU process uses for regular communication and data exchange with other ICs,MCUs etc.??

    As far as I know it should work together with the application UART. But I assume you don't plan to connect more than one UART peers to the nRF52 at the same time ? 

  • Hi Hung,

    Thank you very much for the fast response

    This meant sparkfun_sara_r4 board configuration has select UART_INTERRUPT_DRIVEN =n but UART_MCUMGR (MCUBOOT SMP)is selecting that symbol as y. I'm not very familiar with the sparkfun shield, but you may want to figure out how to change it to select UART_INTERRUPT_DRIVEN =y

    I am not using the sparkfun_sara_r4 , in my configuration I have selected our custom board and have succesfully build and flashed our custom application multiple times and something like this has nver been an issue.

    Is there some configuration option that selects this board or that implicitly affects these configuration options?

    All I did after loading the hello_world sample and flashing it (tested it successfully) on the nRF52840DK is I added a second build configuration using the nRF Connect Extension for VS Code as shown below:

    Is there some other configuration,file or something else I should be paying attention to?

    I have also tryied adding and removing the same items as the nRF52840DK .dts file in the 'chosen' section of the .dts file of our custom board as well as the same uart and button/led nodes and labels with no success either.

    chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,bt-mon-uart = &uart0;
    		zephyr,bt-c2h-uart = &uart0;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};

    I have also tryied to set UART_INTERRUPT_DRIVEN to 'y' with no success. I just get errors about other dependecies that are necessary for the SMPSVR to work (as shown in the guide).

    Am I missing something?

    As far as I know it should work together with the application UART. But I assume you don't plan to connect more than one UART peers to the nRF52 at the same time ? 

    Thank you for the feedback on this its very helpful! No I do not plan on connecting more than one UART at a time.

    Any feedback on the issues mentioned above would be very helpful!

    Thank you!

    Regards,

    Stavros

  • Hi Stavros, 
    Could you send us your board files and maybe your hello world project so we can test here. 

    You may think of making a dummy board files to test and send us that if you don' want to send your actual board files. 

  • Hi Hung,

    I have sent the hello_world project and included the board file (with dummy names) inside the project folder. Thank you very much!

    serial_dfu_hello_world.rar

Related