Skip to content

Remove deprecated --legacyalign from ARMC6 link #10373

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

Closed
wants to merge 5 commits into from

Conversation

kjbracey
Copy link
Contributor

Description

This previously had to be reinstated to avoid failures on certain platforms due to their linker map not having sufficient alignment.

We now have the test infrastructure in place to attempt to remove it and find failures.

Pull request type

[X] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@deepikabhavnani, @JanneKiiskila

@kjbracey
Copy link
Contributor Author

kjbracey commented Apr 11, 2019

Going to be a sequence of scatter file adjustments here - breaking them up into 1 commit per vendor - seem commit messages for notes.

@@ -19,8 +19,7 @@ LR_IROM1 0x00000000 0x40000 { ; load region size_region
.ANY (+RO)
}

; [RAM] Vector table dynamic copy: 79 vectors * 4 bytes = (0x140) - alignment
RW_IRAM1 (0x20000000+0x140) (0x8000-0x140-Stack_Size) { ; RW data
RW_IRAM1 (0x20000000) (0x8000-Stack_Size) { ; RW data

Choose a reason for hiding this comment

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

Why is vector size removed from start of RAM?
In order to remove --legacyalign every section should be 8-byte aligned and for that I updated the linker scripts (most) to have vectors and all other sections to be 8-byte aligned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation is in commit message: 3fea439

Not sure why Maxim is being unusual here - alternatively we could change their code to work like all the other targets.

But I do actually prefer Maxim's approach. It seems a lot simpler - just put the vectors in the normal RAM with an align directive.

Only reason I can see for the special linker map handling is that maybe it avoids stupid padding? The vectors do have a high alignment requirement (512-byte or more), so putting them at the front avoids a linker being dumb and sticking them in the middle with a huge padding block in front of them.

But are any of the linkers really that dumb?

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @ARMmbed/team-maximintegrated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe that commit message isn't clear enough.

Because the Maxim build puts its vectors in main RAM, the main RAM needs to be 512-byte aligned, if you want to turn --legacyalign off.

Taking that unused vector space out makes the main RAM 512-byte aligned.

The vector space is not there in the IAR and GCC maps.

/* [RAM] Vector table dynamic copy: 79 vectors * 4 bytes = 316 bytes (0x13C) */
define symbol __NVIC_start__ = 0x00000000;
define symbol __NVIC_end__ = 0x00000140; /* to be aligned on 8 bytes */
/* [RAM] */

Choose a reason for hiding this comment

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

vector size was 79*4=0x13C (not aligned to 8-byte)
Was updated to be 8-byte aligned as 0x140. I am not sure why are we removing vector region from RAM ?

Copy link

@deepikabhavnani deepikabhavnani left a comment

Choose a reason for hiding this comment

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

In order to remove --legacyalign we need all regions to be 8-byte aligned in linker script.
Please explain why vector region is removed form RAM? OK i see it explained in commit message, but I don;t think it should be part of this PR. It will be good to have it as a separate PR for Maxim

@cmonr
Copy link
Contributor

cmonr commented Apr 12, 2019

@deepikabhavnani Having a seperate commit, while still being related to the PR, is acceptable.
We can get them to review the PR.

@ARMmbed/mbed-os-maintainers Thoughts?

@deepikabhavnani
Copy link

@cmnor - both commits are completely different its two different topics touching linker files.

@cmonr
Copy link
Contributor

cmonr commented Apr 12, 2019

@deepikabhavnani Ah! So it is.

@kjbracey-arm Please either split those commits into their own PR, or make them more relevant to this PR.

@kjbracey
Copy link
Contributor Author

Having made the Maxim changes I'm now getting "Region table handler '__scatterload_copy' needed by entry for RW_IRAM1 was not found." on its build, and I can't figure out why. More work required.

@mbed-ci
Copy link

mbed-ci commented Apr 16, 2019

Test run: FAILED

Summary: 1 of 7 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM

@kjbracey
Copy link
Contributor Author

kjbracey commented Apr 25, 2019

The Maxim approach looks neat, but it doesn't actually work well. It ends up wasting RAM and ROM space because of the large alignment requirement, and the block just gets blopped in the middle of all the static data, with up to 512 bytes of padding.

So I'm going to change the Maxim devices to put the vectors explicitly at the RAM start like other targets.

@ARMmbed/team-maximintegrated ?

Putting the vectors in the main RAM region with 512-byte alignment
causes a number of issues - linker tends to put padding in, and not fill
the gap nicely.

The ARM toolchain actually still had space reserved for the vectors
anyway, and this triggered alignment problems when legacyalign was
turned off - the unused vector space meant the main RAM wasn't 512-byte
aligned.

This commit removes the vector table array from main RAM, and positions
the vectors at RAM start, like other targets. This avoids any excess
padding.

Sizes in the pre-existing ARM maps were in some cases not correct -
either missing the 16 entries for the built-in exceptions, or having a
slightly the wrong number of interrupts (cross-referencing against
MXC_IRQ_COUNT - 32600/32610 = 79, 32620/32625 = 81, 32620C/32630 = 84).

For MAX32625NEXPAQ builds, move the RAM split base to align it to 512
bytes - this is the alignment requirement for the vectors at the start.

squash! Maxim: ARM alignment, remove unneeded vector space

squash! Maxim: Position vectors manually, like other targets
Make sure the default handlers branch to themselves, rather than
branching to the non-weak definition. Should have no effect, but
avoids build warnings.
@maclobdell
Copy link
Contributor

maclobdell commented Apr 25, 2019

@kjbracey-arm Please avoid changing partner code without getting their review and approval. Please engage with partners via @ARmmbed/Team-[Partner] or with the TAM group to discuss proposals, get feedback, or alert them to a change that affects their targets.

@0xc0170
Copy link
Contributor

0xc0170 commented May 3, 2019

@maclobdell will do, I'll tag them the remaining teams now

@0xc0170
Copy link
Contributor

0xc0170 commented May 3, 2019

@ARMmbed/team-maximintegrated @ARMmbed/team-st-mcd Please review

@maclobdell
Copy link
Contributor

cc @bentcooke - please help with the review

@adbridge
Copy link
Contributor

@maclobdell @bentcooke any update on this? Code freeze for 5.13 is one week today...

@0xc0170
Copy link
Contributor

0xc0170 commented May 22, 2019

@ARMmbed/team-st-mcd Please review

@ARMmbed/team-st-mcd Can you please review?

@0xc0170
Copy link
Contributor

0xc0170 commented May 22, 2019

I started CI while finalizing reviews

@mbed-ci
Copy link

mbed-ci commented May 22, 2019

Test run: FAILED

Summary: 1 of 7 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM

@0xc0170
Copy link
Contributor

0xc0170 commented May 23, 2019

@kjbracey-arm The build errors are related - usb tests fail to link with an error __scatterload_copy needed by entry for. I recall we discussed this earlier, what was the solution?

@0xc0170 0xc0170 requested review from evedon and a team May 23, 2019 08:36
Copy link
Contributor

@mark-edgeworth mark-edgeworth left a comment

Choose a reason for hiding this comment

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

This change includes many other changes which appear not to be related to the simple removal of the legacyalign flag. These should be in a separate PR in my view.

@hugueskamba
Copy link
Collaborator

This change includes many other changes which appear not to be related to the simple removal of the legacyalign flag. These should be in a separate PR in my view.

@mark-edgeworth Removing the linker option causes a failure to build for some targets. The other changes are necessary to meet the following requirement of the Mbed OS workflow

Each commit should be the minimum self-contained commit for a change. A commit should always result in a new state that is again in a compilable state. You should (if possible) split large changes into logical smaller commits that help reviewers follow the reasoning behind the full change.

Source: https://os.mbed.com/docs/mbed-os/v5.12/contributing/workflow.html

@kjbracey
Copy link
Contributor Author

usb tests fail to link with an error __scatterload_copy needed by entry for. I recall we discussed this earlier, what was the solution?

There wasn't a proper solution. It appeared to be a linker bug triggered by certain layouts with large alignment. I avoided it by backing away from the "put vectors in general RAM" approach for Maxim.

I'll look at the new failure to see what I can figure out. If it is a linker bug, we might be stuck for a while.

I think this may have to miss 5.13 - I don't think I'll have time to investigate that in time with the other stuff I've got open, and removal of this flag isn't urgent. PR was initially prompted by some suspicion that other weird behaviour may be linked to it, but that issue has been resolved.

@kjbracey
Copy link
Contributor Author

This change includes many other changes which appear not to be related to the simple removal of the legacyalign flag. These should be in a separate PR in my view.

The other changes must be made before the flag can be turned off.

I guess it could be split into a first PR that makes everything aligned, and a second PR that turns off the flag. But GitHub really doesn't know how to handle dependent PRs nicely. You'd have one PR with 4 commits and another with the same 4 commits and 1 more.

Each commit within this dependent series is fairly neatly self-contained - selecting the individual commits to review in the GitHub UI is probably clearer than a trying to look at separate PRs.

@0xc0170
Copy link
Contributor

0xc0170 commented May 24, 2019

Removed 5.13 label for now

@bulislaw
Copy link
Member

It make sense to have it in one PR, if it's all related (change + fix).

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 9, 2019

@kjbracey-arm should we continue with this one for 5.14?

@kjbracey
Copy link
Contributor Author

kjbracey commented Jul 9, 2019

This one's fallen to the bottom of my priority queue, so not sure when I'll be getting back around to it. I don't believe the flag is currently having any ill effects, so maybe park it altogether for now.

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 9, 2019

Let's close it for now.

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

Successfully merging this pull request may close these issues.