element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development DMA prevents FreeRTOS lwip socket connections
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 2 replies
  • Subscribers 311 subscribers
  • Views 341 views
  • Users 0 members are here
Related

DMA prevents FreeRTOS lwip socket connections

Former Member
Former Member over 10 years ago

Hi!

I am using FreeRTOS and lwip to send data over a socket connection (running on cpu0).

When adding DMA transfer of data from the FPGA to cpu1 (running the standalone OS), the socket connection stops working.

FreeRTOS is running but there is no response to socket connection requests.
If DMA initialization is commmented out, then the socket connection works.

The DMA transfer works and was done based on the xaxidma_example_simple_poll.c example implementation.

Has anyone run into this, or have any idea how to solve it?

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 10 years ago

    It turned out that it is the interrupt used to trigger the DMA transfer that causes the problem.
    I am using the PL-PS interrupt port IRQ_F2P (P216), interrupt 61. The socket connection stopped working when using this interrupt.

    After modifying the function DistInit() called by XScuGic_CfgInitialize() in xscugic.c of the BSP, it now works.
    This is an automatically generated file, so it is not a very nice solution.
    Maybe there is a better solution?



    Here is the modified function:

    /*****************************************************************************/
    /**
    *
    * DistInit initializes the distributor of the GIC. The
    * initialization entails:
    *
    * - Write the trigger mode, priority and target CPU
    * - All interrupt sources are disabled
    * - Enable the distributor
    *
    * @paramtInstancePtr is a pointer to the XScuGic instance.
    * @paramtCpuID is the Cpu ID to be initialized.
    *
    * @returntNone
    *
    * @notettNone.
    *
    ******************************************************************************/
    static void DistInit_modified(XScuGic *InstancePtr, u32 CpuID)
    {
    tu32 Int_Id;

    #if USE_AMP==1
    t#warning "Building GIC for AMP"

    t/*
    t * The distrubutor should not be initialized by FreeRTOS in the case of
    t * AMP -- it is assumed that Linux is the master of this device in that
    t * case.
    t */
    treturn;
    #endif

    #if 0 // Removed, prevents socket connection from working
    tXScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET, 0UL);

    t/*
    t * Set the security domains in the int_security registers for
    t * non-secure interrupts
    t * All are secure, so leave at the default. Set to 1 for non-secure
    t * interrupts.
    t */

    t/*
    t * For the Shared Peripheral Interrupts INT_ID[MAX..32], set:
    t */

    t/*
    t * 1. The trigger mode in the int_config register
    t * Only write to the SPI interrupts, so start at 32
    t */

    tfor (Int_Id = 32; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id+=16) {
    tt/*
    tt * Each INT_ID uses two bits, or 16 INT_ID per register
    tt * Set them all to be level sensitive, active HIGH.
    tt */
    ttXScuGic_DistWriteReg(InstancePtr,
    tttttXSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
    ttttt0UL);
    t}


    #define DEFAULT_PRIORITY    0xa0a0a0a0UL
    tfor (Int_Id = 0; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id+=4) {
    tt/*
    tt * 2. The priority using int the priority_level register
    tt * The priority_level and spi_target registers use one byte per
    tt * INT_ID.
    tt * Write a default value that can be changed elsewhere.
    tt */
    ttXScuGic_DistWriteReg(InstancePtr,
    tttttXSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
    tttttDEFAULT_PRIORITY);
    t}
    #endif

    #if 0 // Replaced, prevents socket connection from working
    tfor (Int_Id = 32; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id+=4) {
    #else
    tt// We are using interrupt 61, write only that.
    ttInt_Id = 60;
    #endif
    tt/*
    tt * 3. The CPU interface in the spi_target register
    tt * Only write to the SPI interrupts, so start at 32
    tt */
    ttCpuID |= CpuID << 8;
    ttCpuID |= CpuID << 16;

    ttXScuGic_DistWriteReg(InstancePtr,
    tttt     XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id),
    tttt     CpuID);
    #if 0
    t}
    #endif

    #if 0 // Removed, prevents socket connection from working
    tfor (Int_Id = 0; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id+=32) {
    tt/*
    tt * 4. Enable the SPI using the enable_set register. Leave all
    tt * disabled for now.
    tt */
    ttXScuGic_DistWriteReg(InstancePtr,
    ttXSCUGIC_ENABLE_DISABLE_OFFSET_CALC(XSCUGIC_DISABLE_OFFSET, Int_Id),
    ttt0xFFFFFFFFUL);

    t}

    tXScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET,
    ttttttXSCUGIC_EN_INT_MASK);
    #endif
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Apparently prvGetInterruptControllerInstance() should be used instead of XScuGic_CfgInitialize() as the interrupt controller already is initialized by FreeRTOS, but that is not possible as FreeRTOS is running on the other CPU?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube