Primary stress is on the first syllable in a word, secondary stress is on every other following syllable except if that syllable is final in the word. How to write the stress rules using features.
This is hard to answer, since stress has not been treated as a feature for almost 50 years, and everything about rules has changed in that period. But, since you asked, we could do this in the SPE period.
First, there is no construct "syllable" in that theory, instead, you refer to vowels separated by consonants. The first rule would be:
V → [1stress] / # [-syllabic]₀__
This puts primary (1) stress on the first vowel of the word, ignoring any consonants.
The rule for secondary stress assignment is more challenging. First, you have to assume iterative rule application (which was standard in the era), otherwise you end up with a big problem dealing with "every other". The theory is that you start at one end (in this case, the left end) and look for the first occurrence of some specified sequence, then apply the rule, and re-apply the rule starting right after that. What you are looking for is "an unstressed vowel to the left, skipping over any number of consonants" (I'm setting aside the "not at the end" condition for a moment). So that would be
V → [2stress] / [+syllabic,-stress] [-syllabic]₀__
Suppose you have /papapapapapa/. Apply the primary stress rule, that gives pápapapapapa. Then you try to apply th second rule, which looks for a vowel that is preceded by an unstressed vowel. The first such vowel is the third vowel of the word, so you get pápapàpapapa, and when you re-apply the rule you get pápapàpapàpa.
In order to get "but not final", first thing you have to do is decide if you mean "not the final vowel (ignoring any consonants)", or do you mean "not a vowel in word-final position". That is, should the rule apply to the last a in pápapàpapap? Usually, such conditions reduce to saying "does not apply to the last vowel of the word", meaning that "there is always another vowel after", so
V → [2stress] / [+syllabic,-stress] [-syllabic]₀__[-syllabic]₀ [+syllabic]
I assume that this is a question about actual phonological theory, so this is how the pattern would be described in phonology up to around 1976. However, at that point, the entire theory of phonology changed massively, for example "stress" is no longer a feature, it is a relationship between the network of syllables in a word (and yes there are also syllables in that theory). However, the formalism of writing rules pretty much bit the dust, and was replaced with descriptive statements about the structures that were built, for example "build a binary left-headed foot", unfortunately there were very many theories of what those structural primitives were.
Here's how to write them:
Stress Syllables in English words don't all have the same level of loudness. Some are loud, some are short and quiet, some are in between. English has three levels of stress:
primary stress: the loudest syllable in the word. In one-syllable words, that one syllable has the primary stress (except for a handful of short function words like the, which might not have any stress at all). Primary stress is marked in IPA by putting a raised vertical line [ˈ] at the beginning of the syllable. secondary stress: syllables which aren't completely unstressed, but aren't as loud as the primary stress. Secondary stress is marked with a lowered vertical line [ˌ] at the beginning of the syllable. unstressed syllables: syllables that have no stress at all. In English, almost all of these have schwa [ə] for their vowel, though [i] will also often be unstressed, like the [i] in happy [ˈhæpi]. (Very rarely, another non-schwa vowel might be unstressed, like the [o] of potato [pəˈteto] for most speakers.) Examples:
[əˈnʌf] enough [ˌmænəˈtobə] Manitoba [ˈfotəˌɡɹæf] photograph
A good example of the difference between secondary stress and the complete absence of stress is the final syllable of delegate, used as a verb and used as a noun.
[ˈdɛləˌɡet] verb: You have to delegate your responsibilities [ˈdɛləɡət] noun: We elected a delegate to the national committee.
I just copied this from the University of Manitoba