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

Freertos working commands #409

Open
wants to merge 17 commits into
base: v2-staging
Choose a base branch
from

Conversation

Known4225
Copy link
Contributor

@Known4225 Known4225 commented Jul 17, 2024

This temporary branch implements the following features in freertos:

  • uart communication
  • command handler
  • blink app

@Known4225 Known4225 changed the base branch from v1.2.x to v2-staging July 17, 2024 21:28
@Known4225
Copy link
Contributor Author

Known4225 commented Jul 23, 2024

@npetersen2 ready for review

@codecubepi please review code location under the shared/ folder

@codecubepi codecubepi self-requested a review July 29, 2024 21:03
@codecubepi codecubepi added the v2 For FreeRTOS codebase label Jul 29, 2024
Copy link
Collaborator

@npetersen2 npetersen2 left a comment

Choose a reason for hiding this comment

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

Thanks @Known4225 , I think this is great! I reviewed each file that changed and left some comments as appropriate.

Overall, there are several small things I'd like you to do, but in general, this is looking pretty close to merging from my perspective.

Let's see what @codecubepi has to say in his review

Copy link
Collaborator

Choose a reason for hiding this comment

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

It appears the .gitmodules has to been changed, so why this change for the submodule here?

We should be trying to keep to named version releases from FreeRTOS---which version number does this change correspond to?

#define SERIAL_UPDATES_PER_SEC (10000)
#define SERIAL_INTERVAL_USEC (USEC_IN_SEC / SERIAL_UPDATES_PER_SEC)
#define SERIAL_INTERVAL_TICKS (pdMS_TO_TICKS(1000.0 / SERIAL_UPDATES_PER_SEC))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Include header for pdMS_TO_TICKS macro

Comment on lines 29 to 31
// Create serial task
xTaskCreate(serial_main, (const char *) "uartSerial", configMINIMAL_STACK_SIZE,
NULL, tskIDLE_PRIORITY, &xSerialTaskHandle);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make a new header file that has all the task priorities in one place so we can reason about how the system operates easily.

Let's call it sys/task_priority.h and define priority there, then include and reference these defines in this file from each place that tasks are created.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: this comment applies to all the FreeRTOS tasks you have added, not just this one! There should be numerous priorities defines in this new file.

#include <stdint.h>
#include <stdio.h>

// test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this line

Comment on lines 35 to 37
// Interrupt Controller Instance
// Defined here to be accessable in sys/icc.c
XScuGic InterruptController;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Scary scary! We should not be defining objects in header files.

Who "owns" this object? Where does this object live?

This code probably already was there before this PR... but I see you moved static.

Either way, we need to move this to a single .c file, then expose a extern declaration in the header

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably my bad...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, why this empty file?

I suppose future modules you will port over will need this?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is replacing the old user_config.h file? Perhaps this should be a shared/ resource going forward?

Comment on lines 15 to 19
// Microseconds interval between when task is called
//
// This is what scheduler actually uses to run task,
// but is generated via define above
#define TASK_GAME_INTERVAL_USEC (USEC_IN_SEC / TASK_GAME_UPDATES_PER_SEC)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed your game task has a different way of defining its interval_usec stuff versus the other system tasks.

Eventually, we should be consistent on the "recommended" way of creating tasks.

If we want your game to be kept in the codebase for the full v2 release, we'll need to update this. Otherwise, if the game will get removed, it does not matter

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, do we need the "game" in the codebase? This could become confusing clutter in the future if it's not a required resource.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting commands here :)

} else {
message_status = 2;
xil_printf("CPU0 - FreeRTOS Hello World Example FAILED\r\n");
xil_printf("IF YOU'RE READING THIS THEN A TERRIBLE ERROR HAS OCCURRED!\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ha nice. :)

I am happy to keep this, but let's give the user a little more help here. Revise to say something about memory

Copy link
Contributor

Choose a reason for hiding this comment

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

I need the deleted code to be kept as well, see above comment on deleted code. I think you can probably add a task for your own testing without deleting my tasks.

Comment on lines 114 to 137
#if 1
// CPU0 ONLY:
// This code is required to start CPU1 from CPU0 during boot.
//
// This only applies when booting from flash via the FSBL.
// During development with JTAG loading, these low-level
// calls in this #if block are not needed! However, we'll
// keep them here since it doesn't affect performance...

// Write starting base address for CPU1 PC.
// It will look for this address upon waking up
static const uintptr_t CPU1_START_ADDR = 0xFFFFFFF0;
static const uint32_t CPU1_BASE_ADDR = 0x20080000;
Xil_Out32(CPU1_START_ADDR, CPU1_BASE_ADDR);

// Waits until write has finished
// DMB = Data Memory Barrier
dmb();

// Wake up CPU1 by sending the SEV command
// SEV = Set Event, which causes CPU1 to wake up and jump to CPU1_BASE_ADDR
__asm__("sev");
#endif

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep this code

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please keep... if this is deleted, we'll get nasty merge conflicts when I merge the dual-core stuff.

Copy link
Contributor

@codecubepi codecubepi left a comment

Choose a reason for hiding this comment

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

@Known4225

Good work so far. However it looks like many of your files have either changed minimally or not at all, but are marked as changed, probably due to line endings. If you could revert these EOL changes it will minimize the number of files changed, make review much easier, and Git will not have to store/track meaningless changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is replacing the old user_config.h file? Perhaps this should be a shared/ resource going forward?

Copy link
Contributor

Choose a reason for hiding this comment

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

@npetersen2 Perhaps this should be a shared/ resource going forward?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this should be a shared/ resource?

Comment on lines 15 to 19
// Microseconds interval between when task is called
//
// This is what scheduler actually uses to run task,
// but is generated via define above
#define TASK_GAME_INTERVAL_USEC (USEC_IN_SEC / TASK_GAME_UPDATES_PER_SEC)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, do we need the "game" in the codebase? This could become confusing clutter in the future if it's not a required resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... we really need to determine a way to ditch these absolute paths :(

Probably fine for now though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, what was changed in this file? Line endings?

@Known4225 please be conscious when you commit files of exactly what is changing. I recommend using the Diff View under 'Source Control' in VS Code...

image

If the only thing changing is line endings, please don't commit the change :)

Copy link
Contributor

Choose a reason for hiding this comment

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

See other comments on line endings

Copy link
Contributor

Choose a reason for hiding this comment

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

Line endings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Line endings

Comment on lines 35 to 37
// Interrupt Controller Instance
// Defined here to be accessable in sys/icc.c
XScuGic InterruptController;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably my bad...

@Known4225 Known4225 force-pushed the feature/freertos-singlecore-temp branch from 71beffc to 759f8c5 Compare August 2, 2024 17:34
@Known4225
Copy link
Contributor Author

Known4225 commented Aug 2, 2024

Changes:

  • created task_priority.h file with task priorities for serial, cmds, and the blink and vsi tasks.
  • deleted game app
  • added user_config content
  • removed all line endings and permission issues (git can't seem to figure out that task_blink.c, task_vsi.c, task_vsi.h, and commands.c have been moved AND changed. So it lists them as deleted and re-added with different contents)
  • slight changes to FreeRTOSConfig.h (enabling run time statistics and providing a timer to use)
  • Added timer_stats for run time statistics timer
  • fixed intr.h header definition (now an extern declaration and definition in the source file)
  • included "projdefs.h" in commands.h to provide path to pdMS_TO_TICKS macro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 For FreeRTOS codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants