Skip to content
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

Sprintf - error while sending data to SD card #27367

Closed
EdytaBosacka opened this issue Aug 4, 2020 · 4 comments
Closed

Sprintf - error while sending data to SD card #27367

EdytaBosacka opened this issue Aug 4, 2020 · 4 comments
Assignees
Labels
area: File System bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: low Low impact/importance bug Stale

Comments

@EdytaBosacka
Copy link

EdytaBosacka commented Aug 4, 2020

While I use sprintf function and I want to send some data to .csv file to SD card I get this error: "USAGE FAULT"
"Illegal load of EXC_RETURN into PC"

When I send data to SD card and I dont use "sprintf" function, the problem doesn't occur. Also when I only use sprintf function without using SD card, this function works.
But somehow combining sprintf function with SD card causes an error :(

`#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#include <string.h>
#include <stdio.h>
#include <kernel.h>
#include <stdio.h>
#include <disk/disk_access.h>
#include <logging/log.h>
#include <fs/fs.h>
#include <ff.h>

#define BUF_MAXSIZE	256
typedef unsigned char       u8_t;
typedef unsigned int        u32_t;
static uint8_t rx_buf[BUF_MAXSIZE];

static FATFS fat_fs;

LOG_MODULE_REGISTER(main);
/* mounting info */
static struct fs_mount_t mp = {
	.type = FS_FATFS,
	.fs_data = &fat_fs,
};
int fs_register(enum fs_type type, struct fs_file_system_t *fs);

static const char *disk_mount_pt = "/SD:";

struct device *uart1_dev;

int pozycja = 0;

void main(void)
{
	
    mp.mnt_point = disk_mount_pt;
    int res = fs_mount(&mp);
    char linia[20];

while(1){

    struct fs_file_t zfp;
    int ok = fs_open(&zfp,"/SD:/plink.csv");
    
  
    // if(ok!=0){
    //     printk("Error opening file %s [%d]\n", "/SD:/plink.csv", res);
    //     return res;
    //    };
   
    
    
    // int os_y=2;
    // int os_z=3;
    fs_seek(&zfp, pozycja, FS_SEEK_SET);
  
    int os_x=1;
    int wynik = sprintf(linia,"%x \n", os_x);
    printk("%s",linia);

    //printk("%p wynik=%d",linia,wynik);
    int zapis = fs_write(&zfp, linia, 5); 
    pozycja = pozycja + zapis;
    
    fs_close(&zfp);
   

}
  


}
`

@MaureenHelm
Copy link
Member

Could you please provide some more information about what board and zephyr version you are using?

@MaureenHelm MaureenHelm added area: File System bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Aug 4, 2020
@EdytaBosacka
Copy link
Author

@MaureenHelm My board: nRF52840-dk
Zephyr version: 2.3.0

@nvlsianpu
Copy link
Collaborator

@EdytaBosacka At the first glance this looks like a stack to small issue. Pleas Increase thread stack size.

@github-actions
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: File System bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: low Low impact/importance bug Stale
Projects
None yet
Development

No branches or pull requests

4 participants